1 /***********************************************************************/
2 /* Open Visualization Data Explorer */
3 /* (C) Copyright IBM Corp. 1989,1999 */
4 /* ALL RIGHTS RESERVED */
5 /* This code licensed under the */
6 /* "IBM PUBLIC LICENSE - Open Visualization Data Explorer" */
7 /***********************************************************************/
8
9 #include <dxconfig.h>
10 #include "../base/defines.h"
11
12 #include <sys/types.h>
13
14 #if 0
15 #if defined(windows) && defined(HAVE_WINSOCK_H)
16 #include <winsock.h>
17 #elif defined(HAVE_CYGWIN_SOCKET_H)
18 #include <cygwin/socket.h>
19 #elif defined(HAVE_SYS_SOCKET_H)
20 #include <sys/socket.h>
21 #endif
22 #endif
23
24 #if defined(HAVE_SYS_UTSNAME_H)
25 #include <sys/utsname.h>
26 #endif
27
28 #if defined(HAVE_UNISTD_H)
29 #include <unistd.h>
30 #endif
31
32 #ifdef OS2
33 #include <netdb.h>
34 #endif
35
36 #if defined(sgi)
37 #include <CC/osfcn.h>
38 #endif
39 #if defined(sun4)
40 #include <sysent.h>
41 #endif
42
43
44 #include <X11/X.h>
45 #include <X11/Xlib.h>
46 #include <X11/Xatom.h>
47 #include <X11/keysym.h>
48
49 #include <Xm/CascadeB.h>
50 #include <Xm/DrawingA.h>
51 #include <Xm/Frame.h>
52 #include <Xm/Form.h>
53 #include <Xm/Label.h>
54 #include <Xm/List.h>
55 #include <Xm/RowColumn.h>
56 #include <Xm/ScrolledW.h>
57 #include <Xm/Separator.h>
58 #include <Xm/SelectioB.h>
59 #include <Xm/Text.h>
60
61 #include "ImageWindow.h"
62 #include "DXApplication.h"
63 #include "MsgWin.h"
64 #include "Network.h"
65 #include "ImageNode.h"
66 #include "ButtonInterface.h"
67 #include "ToggleButtonInterface.h"
68 #include "NoOpCommand.h"
69 #include "NoUndoImageCommand.h"
70 #include "ImageApproxCommand.h"
71 #include "ImageConstraintCommand.h"
72 #include "ImageLookCommand.h"
73 #include "ImagePerspectiveCommand.h"
74 #include "ImageRedoCommand.h"
75 #include "ImageResetCommand.h"
76 #include "ImageSetModeCommand.h"
77 #include "ImageSetViewCommand.h"
78 #include "ImageHardwareCommand.h"
79 #include "ImageSoftwareCommand.h"
80 #include "ImageUndoCommand.h"
81 #include "DXChild.h"
82 #include "Stack.h"
83
84 #include "ErrorDialogManager.h"
85 #include "ViewControlDialog.h"
86 #include "RenderingOptionsDialog.h"
87 #include "SetBGColorDialog.h"
88 #include "SetImageNameDialog.h"
89 #include "WarningDialogManager.h"
90 #include "ThrottleDialog.h"
91 #include "AutoAxesDialog.h"
92 #include "SaveImageDialog.h"
93 #include "PrintImageDialog.h"
94 #if WORKSPACE_PAGES
95 #include "ProcessGroupManager.h"
96 #endif
97
98 #include "ProbeNode.h"
99 #include "PickNode.h"
100 #include "Parameter.h"
101 #include "EditorWindow.h"
102 #include "XHandler.h"
103 #include "DXStrings.h"
104 #include "ListIterator.h"
105 #include "CloseWindowCommand.h"
106 #include "PanelAccessManager.h"
107 #include "../widgets/Picture.h"
108 #include "TransferAccelerator.h"
109
110 #include "CascadeMenu.h"
111
112 #ifdef ABS_IN_MATH_H
113 # define abs __Dont_define_abs
114 #endif
115 #include <math.h>
116 #ifdef ABS_IN_MATH_H
117 # undef abs
118 #endif
119
120 #ifdef NEEDS_GETHOSTNAME_DECL
121 extern "C" int gethostname(char *,int);
122 #endif
123
124 #if defined(DXD_WIN)
125 #include <winsock.h>
126 #endif
127
128 #ifndef OS2
129 extern "C" unsigned int sleep(unsigned int);
130 #endif
131
132 // Defines for the where parameter
133 #define FB_WHERE_SWAP 0x00000001
134
135 boolean ImageWindow::NeedsSyncForResize = FALSE;
136
137 #include "IWDefaultResources.h"
138
139 boolean ImageWindow::ClassInitialized = FALSE;
140
141
ImageWindow(boolean isAnchor,Network * network)142 ImageWindow::ImageWindow(boolean isAnchor, Network* network) :
143 DXWindow("imageWindow", isAnchor,
144 theDXApplication->appAllowsImageMenus())
145 {
146 ASSERT(network);
147
148 //
149 // Save associated network and add self to network image list.
150 //
151 this->network = network;
152 this->network->addImage(this);
153
154 this->viewControlDialog = NULL;
155 this->renderingOptionsDialog = NULL;
156 this->backgroundColorDialog = NULL;
157 this->throttleDialog = NULL;
158 this->autoAxesDialog = NULL;
159 this->changeImageNameDialog = NULL;
160 this->saveImageDialog = NULL;
161 this->printImageDialog = NULL;
162
163 this->fbEventHandler = NULL;
164
165 //
166 // Initialize member data.
167 //
168 this->fileMenu = NUL(Widget);
169 this->windowsMenu = NUL(Widget);
170 this->optionsMenu = NUL(Widget);
171 this->managed_state = NUL(Stack*);
172
173 this->fileMenuPulldown = NUL(Widget);
174 this->windowsMenuPulldown = NUL(Widget);
175 this->optionsMenuPulldown = NUL(Widget);
176
177 this->openOption = NUL(CommandInterface*);
178 this->saveOption = NUL(CommandInterface*);
179 this->saveAsOption = NUL(CommandInterface*);
180 this->cfgSettingsCascadeMenu = NULL;
181 this->saveCfgOption = NUL(CommandInterface*);
182 this->openCfgOption = NUL(CommandInterface*);
183 this->loadMacroOption = NUL(CommandInterface*);
184 this->loadMDFOption = NUL(CommandInterface*);
185 #if 0
186 this->quitOption = NUL(CommandInterface*);
187 #endif
188 this->closeOption = NUL(CommandInterface*);
189 this->saveImageOption = NUL(CommandInterface*);
190 this->printImageOption = NUL(CommandInterface*);
191
192 this->openVisualProgramEditorOption = NUL(CommandInterface*);
193 this->openAllControlPanelsOption = NUL(CommandInterface*);
194 this->openControlPanelByNameMenu = NULL;
195 this->openAllColormapEditorsOption = NUL(CommandInterface*);
196 this->messageWindowOption = NUL(CommandInterface*);
197
198 this->renderingOptionsOption = NUL(CommandInterface*);
199 this->autoAxesOption = NUL(CommandInterface*);
200 this->throttleOption = NUL(CommandInterface*);
201 this->viewControlOption = NUL(CommandInterface*);
202 this->modeOptionCascade = NULL;
203 this->undoOption = NUL(CommandInterface*);
204 this->redoOption = NUL(CommandInterface*);
205 this->resetOption = NUL(CommandInterface*);
206 this->changeImageNameOption = NUL(CommandInterface*);
207 this->backgroundColorOption = NUL(CommandInterface*);
208 this->displayRotationGlobeOption = NUL(CommandInterface*);
209 this->imageDepthCascade = NULL;
210 this->imageDepth8Option = NUL(ToggleButtonInterface*);
211 this->imageDepth12Option = NUL(ToggleButtonInterface*);
212 this->imageDepth15Option = NUL(ToggleButtonInterface*);
213 this->imageDepth16Option = NUL(ToggleButtonInterface*);
214 this->imageDepth24Option = NUL(ToggleButtonInterface*);
215 this->imageDepth32Option = NUL(ToggleButtonInterface*);
216 this->setPanelAccessOption = NUL(CommandInterface*);
217 this->onVisualProgramOption = NUL(CommandInterface*);
218
219 //
220 // Intialize state.
221 //
222 this->state.width = 0;
223 this->state.height = 0;
224 this->state.pixmap = XtUnspecifiedPixmap;
225 this->state.gc = NULL;
226 this->state.hardwareWindow = 0;
227 this->state.hardwareRender = FALSE;
228 this->state.hardwareRenderExists = FALSE;
229 this->state.resizeFromServer = FALSE;
230 this->state.frameBuffer = FALSE;
231 this->state.globeDisplayed = FALSE;
232 this->state.degenerateBox = FALSE;
233 this->state.imageCount = 0;
234 this->state.parent.window = 0;
235 this->state.resizeCausesExecution = TRUE;
236
237 this->state.hardwareCamera.undoable = FALSE;
238 this->state.hardwareCamera.redoable = FALSE;
239
240 this->node = NULL;
241 this->directInteraction = FALSE;
242 this->switchingSoftware = FALSE;
243 this->pushedSinceExec = FALSE;
244 this->currentInteractionMode = NONE;
245 this->pendingInteractionMode = NONE;
246 //
247 // Create the commands.
248 //
249 this->renderingOptionsCmd =
250 new NoUndoImageCommand("renderingOptions", this->commandScope,
251 FALSE, this, NoUndoImageCommand::RenderingOptions);
252 this->softwareCmd = new ImageSoftwareCommand("software", this->commandScope,
253 FALSE, this);
254 this->hardwareCmd = new ImageHardwareCommand("hardware", this->commandScope,
255 FALSE, this);
256 this->upNoneCmd = new ImageApproxCommand("upNone",
257 this->commandScope,
258 FALSE, this, TRUE, APPROX_NONE);
259 this->upWireframeCmd = new ImageApproxCommand("upWireframe",
260 this->commandScope,
261 FALSE, this, TRUE, APPROX_WIREFRAME);
262 this->upDotsCmd = new ImageApproxCommand("upDots",
263 this->commandScope,
264 FALSE, this, TRUE, APPROX_DOTS);
265 this->upBoxCmd = new ImageApproxCommand("upBox",
266 this->commandScope,
267 FALSE, this, TRUE, APPROX_BOX);
268 this->downNoneCmd = new ImageApproxCommand("downNone",
269 this->commandScope,
270 FALSE, this, FALSE, APPROX_NONE);
271 this->downWireframeCmd = new ImageApproxCommand("downWireframe",
272 this->commandScope,
273 FALSE, this, FALSE, APPROX_WIREFRAME);
274 this->downDotsCmd = new ImageApproxCommand("downDots",
275 this->commandScope,
276 FALSE, this, FALSE, APPROX_DOTS);
277 this->downBoxCmd = new ImageApproxCommand("downBox",
278 this->commandScope,
279 FALSE, this, FALSE, APPROX_BOX);
280
281 this->autoAxesCmd =
282 new NoUndoImageCommand("autoAxes", this->commandScope,
283 FALSE, this,
284 NoUndoImageCommand::AutoAxes);
285
286 this->throttleCmd =
287 new NoUndoImageCommand("throttle", this->commandScope,
288 FALSE, this, NoUndoImageCommand::Throttle);
289 this->viewControlCmd =
290 new NoUndoImageCommand("viewControl", this->commandScope,
291 FALSE, this,
292 NoUndoImageCommand::ViewControl);
293 this->modeNoneCmd =
294 new ImageSetModeCommand("modeNone", this->commandScope, FALSE,
295 this, NONE);
296 this->modeCameraCmd =
297 new ImageSetModeCommand("modeCamera", this->commandScope, FALSE,
298 this, CAMERA);
299 this->modeCursorsCmd =
300 new ImageSetModeCommand("modeCursors", this->commandScope, FALSE,
301 this, CURSORS);
302 this->modePickCmd =
303 new ImageSetModeCommand("modePick", this->commandScope, FALSE,
304 this, PICK);
305 this->modeNavigateCmd =
306 new ImageSetModeCommand("modeNavigate", this->commandScope, FALSE,
307 this, NAVIGATE);
308 this->modePanZoomCmd =
309 new ImageSetModeCommand("modePanZoom", this->commandScope, FALSE,
310 this, PANZOOM);
311 this->modeRoamCmd =
312 new ImageSetModeCommand("modeRoam", this->commandScope, FALSE,
313 this, ROAM);
314 this->modeRotateCmd =
315 new ImageSetModeCommand("modeRotate", this->commandScope, FALSE,
316 this, ROTATE);
317 this->modeZoomCmd =
318 new ImageSetModeCommand("modeZoom", this->commandScope, FALSE,
319 this, ZOOM);
320
321 this->setViewNoneCmd =
322 new ImageSetViewCommand("setViewNone", this->commandScope, FALSE,
323 this, VIEW_NONE);
324 this->setViewTopCmd =
325 new ImageSetViewCommand("setViewTop", this->commandScope, TRUE,
326 this, VIEW_TOP);
327 this->setViewBottomCmd =
328 new ImageSetViewCommand("setViewBottom", this->commandScope, TRUE,
329 this, VIEW_BOTTOM);
330 this->setViewFrontCmd =
331 new ImageSetViewCommand("setViewFront", this->commandScope, TRUE,
332 this, VIEW_FRONT);
333 this->setViewBackCmd =
334 new ImageSetViewCommand("setViewBack", this->commandScope, TRUE,
335 this, VIEW_BACK);
336 this->setViewLeftCmd =
337 new ImageSetViewCommand("setViewLeft", this->commandScope, TRUE,
338 this, VIEW_LEFT);
339 this->setViewRightCmd =
340 new ImageSetViewCommand("setViewRight", this->commandScope, TRUE,
341 this, VIEW_RIGHT);
342 this->setViewDiagonalCmd =
343 new ImageSetViewCommand("setViewDiagonal", this->commandScope, TRUE,
344 this, VIEW_DIAGONAL);
345 this->setViewOffTopCmd =
346 new ImageSetViewCommand("setViewOffTop", this->commandScope, TRUE,
347 this, VIEW_OFF_TOP);
348 this->setViewOffBottomCmd =
349 new ImageSetViewCommand("setViewOffBottom", this->commandScope, TRUE,
350 this, VIEW_OFF_BOTTOM);
351 this->setViewOffFrontCmd =
352 new ImageSetViewCommand("setViewOffFront", this->commandScope, TRUE,
353 this, VIEW_OFF_FRONT);
354 this->setViewOffBackCmd =
355 new ImageSetViewCommand("setViewOffBack", this->commandScope, TRUE,
356 this, VIEW_OFF_BACK);
357 this->setViewOffLeftCmd =
358 new ImageSetViewCommand("setViewOffLeft", this->commandScope, TRUE,
359 this, VIEW_OFF_LEFT);
360 this->setViewOffRightCmd =
361 new ImageSetViewCommand("setViewOffRight", this->commandScope, TRUE,
362 this, VIEW_OFF_RIGHT);
363 this->setViewOffDiagonalCmd =
364 new ImageSetViewCommand("setViewOffDiagonal", this->commandScope, TRUE,
365 this, VIEW_OFF_DIAGONAL);
366
367 this->perspectiveCmd =
368 new ImagePerspectiveCommand("perspective", this->commandScope,
369 TRUE, this, TRUE);
370 this->parallelCmd =
371 new ImagePerspectiveCommand("parallel", this->commandScope,
372 TRUE, this, FALSE);
373 this->constrainNoneCmd =
374 new ImageConstraintCommand("constrainNone", this->commandScope, TRUE,
375 this, CONSTRAINT_NONE);
376 this->constrainXCmd =
377 new ImageConstraintCommand("constrainX", this->commandScope, TRUE,
378 this, CONSTRAINT_X);
379 this->constrainYCmd =
380 new ImageConstraintCommand("constrainY", this->commandScope, TRUE,
381 this, CONSTRAINT_Y);
382 this->constrainZCmd =
383 new ImageConstraintCommand("constrainZ", this->commandScope, TRUE,
384 this, CONSTRAINT_Z);
385
386 this->lookForwardCmd =
387 new ImageLookCommand("lookForwardCmd", this->commandScope, TRUE,
388 this, LOOK_FORWARD);
389 this->lookLeft45Cmd =
390 new ImageLookCommand("lookLeft45Cmd", this->commandScope, TRUE,
391 this, LOOK_LEFT45);
392 this->lookRight45Cmd =
393 new ImageLookCommand("lookRight45Cmd", this->commandScope, TRUE,
394 this, LOOK_RIGHT45);
395 this->lookUp45Cmd =
396 new ImageLookCommand("lookUp45Cmd", this->commandScope, TRUE,
397 this, LOOK_UP45);
398 this->lookDown45Cmd =
399 new ImageLookCommand("lookDown45Cmd", this->commandScope, TRUE,
400 this, LOOK_DOWN45);
401 this->lookLeft90Cmd =
402 new ImageLookCommand("lookLeft90Cmd", this->commandScope, TRUE,
403 this, LOOK_LEFT90);
404 this->lookRight90Cmd =
405 new ImageLookCommand("lookRight90Cmd", this->commandScope, TRUE,
406 this, LOOK_RIGHT90);
407 this->lookUp90Cmd =
408 new ImageLookCommand("lookUp90Cmd", this->commandScope, TRUE,
409 this, LOOK_UP90);
410 this->lookDown90Cmd =
411 new ImageLookCommand("lookDown90Cmd", this->commandScope, TRUE,
412 this, LOOK_DOWN90);
413 this->lookBackwardCmd =
414 new ImageLookCommand("lookBackwardCmd", this->commandScope, TRUE,
415 this, LOOK_BACKWARD);
416 this->lookAlignCmd =
417 new ImageLookCommand("lookAlignCmd", this->commandScope, TRUE,
418 this, LOOK_ALIGN);
419
420
421 this->undoCmd =
422 new ImageUndoCommand("undo", this->commandScope, FALSE, this);
423 this->redoCmd =
424 new ImageRedoCommand("redo", this->commandScope, FALSE, this);
425 this->resetCmd =
426 new ImageResetCommand("reset", this->commandScope,
427 this->directInteractionAllowed(), this);
428
429 // FIXME: this should be DXApplication command
430 this->openVPECmd =
431 new NoUndoImageCommand("openVPE", this->commandScope, TRUE,
432 this, NoUndoImageCommand::OpenVPE);
433 this->displayRotationGlobeCmd =
434 new NoUndoImageCommand("displayRotationGlobe", this->commandScope,
435 FALSE, this, NoUndoImageCommand::DisplayGlobe);
436
437 this->backgroundColorCmd =
438 new NoUndoImageCommand("setBackgroundColor", this->commandScope,
439 FALSE, this, NoUndoImageCommand::SetBGColor);
440
441 if (!theDXApplication->appLimitsImageOptions()) {
442 this->imageDepth8Cmd =
443 new NoUndoImageCommand("imageDepth8", this->commandScope,
444 FALSE, this, NoUndoImageCommand::Depth8);
445
446 this->imageDepth12Cmd =
447 new NoUndoImageCommand("imageDepth12", this->commandScope,
448 FALSE, this, NoUndoImageCommand::Depth12);
449
450 this->imageDepth15Cmd =
451 new NoUndoImageCommand("imageDepth15", this->commandScope,
452 FALSE, this, NoUndoImageCommand::Depth15);
453
454 this->imageDepth16Cmd =
455 new NoUndoImageCommand("imageDepth16", this->commandScope,
456 FALSE, this, NoUndoImageCommand::Depth16);
457
458 this->imageDepth24Cmd =
459 new NoUndoImageCommand("imageDepth24", this->commandScope,
460 FALSE, this, NoUndoImageCommand::Depth24);
461
462 this->imageDepth32Cmd =
463 new NoUndoImageCommand("imageDepth32", this->commandScope,
464 FALSE, this, NoUndoImageCommand::Depth32);
465
466 this->changeImageNameCmd =
467 new NoUndoImageCommand("changeImageName", this->commandScope,
468 FALSE, this, NoUndoImageCommand::ChangeImageName);
469 // FIXME: this should be DXApplication command
470 this->setPanelAccessCmd =
471 new NoUndoImageCommand("setPanelAccess", this->commandScope,
472 FALSE, this, NoUndoImageCommand::SetCPAccess);
473 } else {
474 this->changeImageNameCmd = NULL;
475 this->setPanelAccessCmd = NULL;
476 this->imageDepth8Cmd = NULL;
477 this->imageDepth12Cmd = NULL;
478 this->imageDepth15Cmd = NULL;
479 this->imageDepth16Cmd = NULL;
480 this->imageDepth24Cmd = NULL;
481 this->imageDepth32Cmd = NULL;
482 }
483
484 // FIXME: this should be DXApplication command
485 if (theDXApplication->appAllowsImageSaving())
486 this->saveImageCmd =
487 new NoUndoImageCommand("saveImage", this->commandScope,
488 FALSE, this, NoUndoImageCommand::SaveAsImage);
489 else
490 this->saveImageCmd = NULL;
491
492 // FIXME: this should be DXApplication command
493 if (theDXApplication->appAllowsImagePrinting())
494 this->printImageCmd =
495 new NoUndoImageCommand("printImage", this->commandScope,
496 FALSE, this, NoUndoImageCommand::PrintImage);
497 else
498 this->printImageCmd = NULL;
499
500 this->closeCmd =
501 new CloseWindowCommand("close",this->commandScope,TRUE,this);
502
503 this->allowDirectInteraction(FALSE);
504
505 //this->currentProbeNode = NULL;
506 this->currentProbeInstance = -1;
507 this->currentPickInstance = -1;
508 //this->currentPickNode = NULL;
509
510 this->resetWindowTitle();
511
512 this->cameraInitialized = False;
513
514 //
515 // By default the only startup image window is the anchor window.
516 //
517 this->startup = this->anchor || (this->network->getImageCount() == 1);
518
519 this->reset_eor_wp = NUL(XtWorkProcId);
520
521 //
522 // Rather than triggering an execution following a window resize,
523 // Queue the execution so that it happens soon after the execution
524 // but not immediately after. This gives better results for users
525 // with window mgrs that deliver tons of resize events
526 //
527 this->execute_after_resize_to = 0;
528
529 //
530 // Install the default resources for THIS class (not the derived classes)
531 //
532 if (NOT ImageWindow::ClassInitialized)
533 {
534 ASSERT(theApplication);
535 ImageWindow::ClassInitialized = TRUE;
536 this->installDefaultResources(theApplication->getRootWidget());
537 }
538 }
539
540
~ImageWindow()541 ImageWindow::~ImageWindow()
542 {
543
544 //
545 // Purify caught an abr originating in ImageWindow_RedrawCB
546 // if you do File/New with many opened image tools. So remove
547 // the callback prior to going completely away.
548 //
549 if (this->getCanvas()) {
550 XtRemoveCallback(this->getCanvas(),
551 XmNexposeCallback,
552 (XtCallbackProc)ImageWindow_RedrawCB,
553 (XtPointer)this);
554 if(this->state.gc)
555 XFreeGC(XtDisplay(this->getCanvas()),this->state.gc);
556 this->state.gc = NULL;
557 }
558
559
560 if(this->state.hardwareRenderExists)
561 {
562 this->sendClientMessage(this->atoms.gl_destroy_window);
563 this->wait4GLAcknowledge();
564 }
565
566 XmUpdateDisplay(this->getCanvas());
567 XSync(XtDisplay(this->getCanvas()), False);
568
569 //
570 // Disconnect from the node
571 //
572 DisplayNode *n = (DisplayNode*)this->node;
573 if (n) {
574 this->node = NULL;
575 n->associateImage(NULL);
576 }
577
578 if (this->changeImageNameDialog)
579 delete this->changeImageNameDialog;
580 if (this->viewControlDialog)
581 delete this->viewControlDialog;
582 if (this->renderingOptionsDialog)
583 delete this->renderingOptionsDialog;
584 if (this->backgroundColorDialog)
585 delete this->backgroundColorDialog;
586 if (this->throttleDialog)
587 delete this->throttleDialog;
588 if (this->autoAxesDialog)
589 delete this->autoAxesDialog;
590 if (this->saveImageDialog)
591 delete this->saveImageDialog;
592 if (this->printImageDialog)
593 delete this->printImageDialog;
594 if (this->fbEventHandler)
595 delete this->fbEventHandler;
596
597 //
598 // File menu optoins
599 //
600 if (this->openOption) delete this->openOption;
601 if (this->saveOption) delete this->saveOption;
602 if (this->saveAsOption) delete this->saveAsOption;
603 if (this->saveCfgOption) delete this->saveCfgOption;
604 if (this->openCfgOption) delete this->openCfgOption;
605 if (this->cfgSettingsCascadeMenu) delete this->cfgSettingsCascadeMenu;
606 if (this->loadMacroOption) delete this->loadMacroOption;
607 if (this->loadMDFOption) delete this->loadMDFOption;
608 #if 0
609 if (this->quitOption) delete this->quitOption;
610 #endif
611 if (this->closeOption) delete this->closeOption;
612 if (this->saveImageOption) delete this->saveImageOption;
613 if (this->printImageOption) delete this->printImageOption;
614
615 //
616 // Windows options
617 //
618 if (this->openVisualProgramEditorOption) delete this->openVisualProgramEditorOption;
619 if (this->openAllControlPanelsOption) delete this->openAllControlPanelsOption;
620 if (this->openControlPanelByNameMenu) delete this->openControlPanelByNameMenu;
621 if (this->openAllColormapEditorsOption) delete this->openAllColormapEditorsOption;
622 if (this->messageWindowOption) delete this->messageWindowOption;
623 this->panelNameList.clear();
624 this->panelGroupList.clear();
625
626 //
627 // Option options
628 //
629 if (this->renderingOptionsOption) delete this->renderingOptionsOption;
630 if (this->autoAxesOption) delete this->autoAxesOption;
631 if (this->throttleOption) delete this->throttleOption;
632 if (this->viewControlOption) delete this->viewControlOption;
633 if (this->modeOptionCascade) delete this->modeOptionCascade;
634 if (this->undoOption) delete this->undoOption;
635 if (this->redoOption) delete this->redoOption;
636 if (this->resetOption) delete this->resetOption;
637 if (this->changeImageNameOption) delete this->changeImageNameOption;
638 if (this->backgroundColorOption) delete this->backgroundColorOption;
639 if (this->displayRotationGlobeOption) delete this->displayRotationGlobeOption;
640 //
641 // Delete the image depth cascade which contains the imageDepth*Options.
642 // Deleting the cascade deletes the contained options so we don't need
643 // to explicitly delete them ourselves.
644 //
645 if (this->imageDepthCascade) delete this->imageDepthCascade;
646
647 if (this->setPanelAccessOption) delete this->setPanelAccessOption;
648 if (this->onVisualProgramOption) delete this->onVisualProgramOption;
649
650 //
651 // Delete the commands after the command interfaces.
652 //
653 delete this->renderingOptionsCmd;
654 delete this->softwareCmd;
655 delete this->hardwareCmd;
656 delete this->upNoneCmd;
657 delete this->upWireframeCmd;
658 delete this->upDotsCmd;
659 delete this->upBoxCmd;
660 delete this->downNoneCmd;
661 delete this->downWireframeCmd;
662 delete this->downDotsCmd;
663 delete this->downBoxCmd;
664 delete this->autoAxesCmd;
665 delete this->throttleCmd;
666 if (this->imageDepth8Cmd) delete this->imageDepth8Cmd;
667 if (this->imageDepth12Cmd) delete this->imageDepth12Cmd;
668 if (this->imageDepth15Cmd) delete this->imageDepth15Cmd;
669 if (this->imageDepth16Cmd) delete this->imageDepth16Cmd;
670 if (this->imageDepth24Cmd) delete this->imageDepth24Cmd;
671 if (this->imageDepth32Cmd) delete this->imageDepth32Cmd;
672 if (this->setPanelAccessCmd) delete this->setPanelAccessCmd;
673 delete this->viewControlCmd;
674 delete this->modeNoneCmd;
675 delete this->modeCameraCmd;
676 delete this->modeCursorsCmd;
677 delete this->modePickCmd;
678 delete this->modeNavigateCmd;
679 delete this->modePanZoomCmd;
680 delete this->modeRoamCmd;
681 delete this->modeRotateCmd;
682 delete this->modeZoomCmd;
683 delete this->setViewNoneCmd;
684 delete this->setViewTopCmd;
685 delete this->setViewBottomCmd;
686 delete this->setViewFrontCmd;
687 delete this->setViewBackCmd;
688 delete this->setViewLeftCmd;
689 delete this->setViewRightCmd;
690 delete this->setViewDiagonalCmd;
691 delete this->setViewOffTopCmd;
692 delete this->setViewOffBottomCmd;
693 delete this->setViewOffFrontCmd;
694 delete this->setViewOffBackCmd;
695 delete this->setViewOffLeftCmd;
696 delete this->setViewOffRightCmd;
697 delete this->setViewOffDiagonalCmd;
698 delete this->perspectiveCmd;
699 delete this->parallelCmd;
700 delete this->constrainNoneCmd;
701 delete this->constrainXCmd;
702 delete this->constrainYCmd;
703 delete this->constrainZCmd;
704 delete this->lookForwardCmd;
705 delete this->lookLeft45Cmd;
706 delete this->lookRight45Cmd;
707 delete this->lookUp45Cmd;
708 delete this->lookDown45Cmd;
709 delete this->lookLeft90Cmd;
710 delete this->lookRight90Cmd;
711 delete this->lookUp90Cmd;
712 delete this->lookDown90Cmd;
713 delete this->lookBackwardCmd;
714 delete this->lookAlignCmd;
715 delete this->closeCmd;
716 delete this->undoCmd;
717 delete this->redoCmd;
718 delete this->resetCmd;
719 if (this->changeImageNameCmd) delete this->changeImageNameCmd;
720 delete this->backgroundColorCmd;
721 delete this->displayRotationGlobeCmd;
722 if (this->saveImageCmd) delete this->saveImageCmd;
723 if (this->printImageCmd) delete this->printImageCmd;
724 if (this->openVPECmd) delete this->openVPECmd;
725
726
727 //
728 // Remove self from the network image list.
729 //
730 this->network->removeImage(this);
731 if (this->managed_state) delete this->managed_state;
732
733 if (this->reset_eor_wp) XtRemoveWorkProc(this->reset_eor_wp);
734 if (this->execute_after_resize_to) XtRemoveTimeOut(this->execute_after_resize_to);
735 }
736
737
738 //
739 // Install the default resources for this class.
740 //
installDefaultResources(Widget baseWidget)741 void ImageWindow::installDefaultResources(Widget baseWidget)
742 {
743 this->setDefaultResources(baseWidget, ImageWindow::DefaultResources);
744 this->DXWindow::installDefaultResources(baseWidget);
745 }
initialize()746 void ImageWindow::initialize()
747 {
748 //
749 // Now, call the superclass initialize().
750 //
751 this->DXWindow::initialize();
752
753 //
754 // Make sure that this window is resizable.
755 this->allowResize(TRUE);
756
757 XtRealizeWidget(this->getRootWidget());
758
759 this->completePictureCreation();
760
761 if(this->node)
762 {
763 this->changeDepth(((ImageNode *)(this->node))->getDepth());
764 }
765 }
766
767 //
768 // Get Vals from the picture widget that we need to keep in synch.
769 // Also set up exposure handling for the frame buffer overlay.
770 //
completePictureCreation()771 void ImageWindow::completePictureCreation()
772 {
773
774 /*
775 * Determine if we are working with a frame buffer.
776 */
777 Boolean frameBuffer;
778 Window overlayWID;
779 int itrans;
780 int irot;
781 XtVaGetValues(this->getCanvas(),
782 XmNframeBuffer, &frameBuffer,
783 XmNoverlayWid, &overlayWID,
784 XmNtranslateSpeed, &itrans,
785 XmNrotateSpeed, &irot,
786 NULL);
787 this->state.navigateTranslateSpeed = itrans;
788 this->state.navigateRotateSpeed = irot;
789 this->state.frameBuffer = frameBuffer;
790 if (frameBuffer)
791 {
792 this->fbEventHandler = new XHandler(Expose, overlayWID,
793 HandleExposures, (void*)this);
794 }
795 }
796
installCallbacks()797 void ImageWindow::installCallbacks()
798 {
799 Widget canvas = this->getCanvas();
800
801 //
802 // Add callbacks
803 //
804 XtAddCallback(canvas,
805 XmNexposeCallback,
806 (XtCallbackProc)ImageWindow_RedrawCB,
807 (XtPointer)this);
808 XtAddCallback(canvas,
809 XmNresizeCallback,
810 (XtCallbackProc)ImageWindow_ResizeCB,
811 (XtPointer)this);
812 XtAddCallback(canvas,
813 XmNzoomCallback,
814 (XtCallbackProc)ImageWindow_ZoomCB,
815 (XtPointer)this);
816 XtAddCallback(canvas,
817 XmNroamCallback,
818 (XtCallbackProc)ImageWindow_RoamCB,
819 (XtPointer)this);
820 XtAddCallback(canvas,
821 XmNnavigateCallback,
822 (XtCallbackProc)ImageWindow_NavigateCB,
823 (XtPointer)this);
824 XtAddCallback(canvas,
825 XmNrotationCallback,
826 (XtCallbackProc)ImageWindow_RotationCB,
827 (XtPointer)this);
828 XtAddCallback(canvas,
829 XmNcursorCallback,
830 (XtCallbackProc)ImageWindow_CursorCB,
831 (XtPointer)this);
832 XtAddCallback(canvas,
833 XmNpickCallback,
834 (XtCallbackProc)ImageWindow_PickCB,
835 (XtPointer)this);
836 XtAddCallback(canvas,
837 XmNmodeCallback,
838 (XtCallbackProc)ImageWindow_ModeCB,
839 (XtPointer)this);
840 XtAddCallback(canvas,
841 XmNundoCallback,
842 (XtCallbackProc)ImageWindow_UndoCB,
843 (XtPointer)this);
844 XtAddCallback(canvas,
845 XmNkeyCallback,
846 (XtCallbackProc)ImageWindow_KeyCB,
847 (XtPointer)this);
848 XtAddCallback(canvas,
849 XmNclientMessageCallback,
850 (XtCallbackProc)ImageWindow_ClientMessageCB,
851 (XtPointer)this);
852 XtAddCallback(canvas,
853 XmNpropertyNotifyCallback,
854 (XtCallbackProc)ImageWindow_PropertyNotifyCB,
855 (XtPointer)this);
856
857 this->installComponentHelpCallback(canvas);
858 }
859
manage()860 void ImageWindow::manage()
861 {
862 this->DXWindow::manage();
863
864 if (this->state.frameBuffer)
865 {
866 // FIXME: is this really intalling a handler on each manage?
867 XtAddEventHandler(this->getRootWidget(),
868 StructureNotifyMask,
869 False, (XtEventHandler)ImageWindow_TrackFrameBufferEH, (XtPointer)this);
870 }
871 }
872
unmanage()873 void ImageWindow::unmanage()
874 {
875 if(this->state.frameBuffer)
876 {
877 XtRemoveEventHandler(this->getRootWidget(),
878 StructureNotifyMask,
879 False, (XtEventHandler)ImageWindow_TrackFrameBufferEH, (XtPointer)this);
880 }
881 this->DXWindow::unmanage();
882
883 if (this->viewControlDialog)
884 this->viewControlDialog->unmanage();
885 if (this->renderingOptionsDialog)
886 this->renderingOptionsDialog->unmanage();
887 if (this->backgroundColorDialog)
888 this->backgroundColorDialog->unmanage();
889 if (this->throttleDialog)
890 this->throttleDialog->unmanage();
891 if (this->autoAxesDialog)
892 this->autoAxesDialog->unmanage();
893 if (this->changeImageNameDialog)
894 this->changeImageNameDialog->unmanage();
895 }
896
createWorkArea(Widget parent)897 Widget ImageWindow::createWorkArea(Widget parent)
898 {
899 Widget outerFrame;
900 Widget innerFrame;
901
902 ASSERT(parent);
903
904 /*
905 * Create atoms needed for GL support.
906 */
907 this->atoms.stop =
908 XInternAtom(XtDisplay(parent), "StopInteraction", False);
909 this->atoms.set_view =
910 XInternAtom(XtDisplay(parent), "Set_View", False);
911 this->atoms.start_rotate =
912 XInternAtom(XtDisplay(parent), "StartRotateInteraction", False);
913 this->atoms.start_zoom =
914 XInternAtom(XtDisplay(parent), "StartZoomInteraction", False);
915 this->atoms.start_panzoom =
916 XInternAtom(XtDisplay(parent), "StartPanZoomInteraction", False);
917 this->atoms.start_cursor =
918 XInternAtom(XtDisplay(parent), "StartCursorInteraction", False);
919 this->atoms.start_roam =
920 XInternAtom(XtDisplay(parent), "StartRoamInteraction", False);
921 this->atoms.start_navigate =
922 XInternAtom(XtDisplay(parent), "StartNavigateInteraction",False);
923 this->atoms.from_vector =
924 XInternAtom(XtDisplay(parent), "FromPoint", False);
925 this->atoms.up_vector =
926 XInternAtom(XtDisplay(parent), "UpVector", False);
927 this->atoms.zoom1 =
928 XInternAtom(XtDisplay(parent), "Zoom1", False);
929 this->atoms.zoom2 =
930 XInternAtom(XtDisplay(parent), "Zoom2", False);
931 this->atoms.roam =
932 XInternAtom(XtDisplay(parent), "RoamPoint", False);
933 this->atoms.cursor_change =
934 XInternAtom(XtDisplay(parent), "CursorChange", False);
935 this->atoms.cursor_constraint =
936 XInternAtom(XtDisplay(parent), "SetCursorConstraint", False);
937 this->atoms.cursor_speed =
938 XInternAtom(XtDisplay(parent), "SetCursorSpeed", False);
939 this->atoms.gl_window0 =
940 XInternAtom(XtDisplay(parent), "GLWindow0", False);
941 this->atoms.gl_window1 =
942 XInternAtom(XtDisplay(parent), "GLWindow1", False);
943 this->atoms.gl_window2 =
944 XInternAtom(XtDisplay(parent), "GLWindow2", False);
945 this->atoms.gl_window2_execute =
946 XInternAtom(XtDisplay(parent), "GLWindow2Execute", False);
947 this->atoms.dx_flag =
948 XInternAtom(XtDisplay(parent), "DX_FLAG", False);
949 this->atoms.dx_pixmap_id =
950 XInternAtom(XtDisplay(parent), "DX_PIXMAP_ID", False);
951 this->atoms.display_globe =
952 XInternAtom(XtDisplay(parent), "DisplayGlobe", False);
953 this->atoms.motion =
954 XInternAtom(XtDisplay(parent), "NavigateMotion", False);
955 this->atoms.pivot =
956 XInternAtom(XtDisplay(parent), "NavigatePivot", False);
957 this->atoms.undoable =
958 XInternAtom(XtDisplay(parent), "CameraUndoable", False);
959 this->atoms.redoable =
960 XInternAtom(XtDisplay(parent), "CameraRedoable", False);
961 this->atoms.redo_camera =
962 XInternAtom(XtDisplay(parent), "RedoCamera", False);
963 this->atoms.undo_camera =
964 XInternAtom(XtDisplay(parent), "UndoCamera", False);
965 this->atoms.push_camera =
966 XInternAtom(XtDisplay(parent), "PushCamera", False);
967 this->atoms.button_mapping1 =
968 XInternAtom(XtDisplay(parent), "ButtonMapping1", False);
969 this->atoms.button_mapping2 =
970 XInternAtom(XtDisplay(parent), "ButtonMapping2", False);
971 this->atoms.button_mapping3 =
972 XInternAtom(XtDisplay(parent), "ButtonMapping3", False);
973 this->atoms.navigate_look_at =
974 XInternAtom(XtDisplay(parent), "NavigateLookAt", False);
975 this->atoms.execute_on_change =
976 XInternAtom(XtDisplay(parent), "ExecuteOnChange", False);
977 this->atoms.gl_destroy_window =
978 XInternAtom(XtDisplay(parent), "GLDestroyWindow", False);
979 this->atoms.gl_shutdown =
980 XInternAtom(XtDisplay(parent), "GLShutdown", False);
981 this->atoms.start_pick =
982 XInternAtom(XtDisplay(parent), "StartPickInteraction", False);
983 this->atoms.pick_point =
984 XInternAtom(XtDisplay(parent), "PickPoint", False);
985 this->atoms.image_reset =
986 XInternAtom(XtDisplay(parent), "ImageReset", False);
987
988 //
989 // Create the outer and inner frame.
990 //
991 outerFrame =
992 XtVaCreateManagedWidget
993 ("imageOuterFrame",
994 xmFrameWidgetClass,
995 parent,
996 XmNshadowType, XmSHADOW_OUT,
997 XmNmarginHeight, 5,
998 XmNmarginWidth, 5,
999 NULL);
1000
1001 innerFrame =
1002 XtVaCreateManagedWidget
1003 ("imageInnerFrame",
1004 xmFrameWidgetClass,
1005 outerFrame,
1006 XmNshadowType, XmSHADOW_IN,
1007 NULL);
1008
1009 this->form =
1010 XtVaCreateManagedWidget
1011 ("imageInnerFrame",
1012 xmFormWidgetClass,
1013 innerFrame,
1014 XmNmarginWidth, 0,
1015 XmNmarginHeight, 0,
1016 XmNbackground, BlackPixel(XtDisplay(innerFrame), 0),
1017 NULL);
1018
1019 //
1020 // Create the canvas.
1021 //
1022 this->canvas =
1023 XtVaCreateManagedWidget
1024 ("imageCanvas",
1025 xmPictureWidgetClass,
1026 this->form,
1027 XmNsendMotion, False,
1028 XmNmode, XmNULL_MODE,
1029 XmNshowRotatingBBox, False,
1030 XmNglobeRadius, 10,
1031 XmNleftAttachment, XmATTACH_FORM,
1032 XmNrightAttachment, XmATTACH_FORM,
1033 XmNtopAttachment, XmATTACH_FORM,
1034 XmNbottomAttachment, XmATTACH_FORM,
1035 XmNhighlightPixmap, XmUNSPECIFIED_PIXMAP,
1036 NULL);
1037
1038 this->completePictureCreation();
1039
1040 //
1041 // Add callbacks
1042 //
1043 this->installCallbacks();
1044
1045 //
1046 // Return the topmost widget of the work area.
1047 //
1048 return outerFrame;
1049 }
1050
1051
createFileMenu(Widget parent)1052 void ImageWindow::createFileMenu(Widget parent)
1053 {
1054 ASSERT(parent);
1055 int buttons = 0;
1056 Widget pulldown;
1057
1058 //
1059 // Create "File" menu and options.
1060 //
1061 pulldown =
1062 this->fileMenuPulldown =
1063 XmCreatePulldownMenu(parent, "fileMenuPulldown", NUL(ArgList), 0);
1064 this->fileMenu =
1065 XtVaCreateManagedWidget
1066 ("fileMenu",
1067 xmCascadeButtonWidgetClass,
1068 parent,
1069 XmNsubMenuId, pulldown,
1070 NULL);
1071
1072 //
1073 // Net file options.
1074 //
1075
1076 if (theDXApplication->appAllowsImageRWNetFile()) {
1077 this->openOption =
1078 new ButtonInterface(pulldown, "imageOpenOption",
1079 theDXApplication->openFileCmd);
1080
1081 this->createFileHistoryMenu(pulldown);
1082
1083 this->saveOption =
1084 new ButtonInterface(pulldown, "imageSaveOption",
1085 this->network->getSaveCommand());
1086
1087 this->saveAsOption =
1088 new ButtonInterface(pulldown, "imageSaveAsOption",
1089 this->network->getSaveAsCommand());
1090 buttons = 1;
1091 }
1092
1093
1094 if (theDXApplication->appAllowsRWConfig()) {
1095
1096 Command *openCfgCmd = this->network->getOpenCfgCommand();
1097 Command *saveCfgCmd = this->network->getSaveCfgCommand();
1098 if (openCfgCmd && saveCfgCmd) {
1099 CascadeMenu *cascade_menu = this->cfgSettingsCascadeMenu =
1100 new CascadeMenu("imageSettingsCascade",pulldown);
1101 Widget menu_parent = cascade_menu->getMenuItemParent();
1102 this->saveCfgOption = new ButtonInterface(menu_parent,
1103 "imageSaveCfgOption", saveCfgCmd);
1104 this->openCfgOption = new ButtonInterface(menu_parent,
1105 "imageOpenCfgOption", openCfgCmd);
1106 } else if (openCfgCmd) {
1107 this->openCfgOption = new ButtonInterface(pulldown,
1108 "imageOpenCfgOption", openCfgCmd);
1109 } else if (saveCfgCmd) {
1110 this->saveCfgOption = new ButtonInterface(pulldown,
1111 "imageSaveCfgOption", saveCfgCmd);
1112 }
1113
1114
1115 buttons = 1;
1116 }
1117
1118
1119
1120 //
1121 // Macro/mdf options.
1122 //
1123 if (buttons) {
1124 XtVaCreateManagedWidget
1125 ("optionSeparator", xmSeparatorWidgetClass, pulldown, NULL);
1126 buttons = 0;
1127 }
1128 if (theDXApplication->appAllowsImageLoad()) {
1129 this->loadMacroOption =
1130 new ButtonInterface(pulldown, "imageLoadMacroOption",
1131 theDXApplication->loadMacroCmd);
1132 this->loadMDFOption =
1133 new ButtonInterface(pulldown, "imageLoadMDFOption",
1134 theDXApplication->loadMDFCmd);
1135 buttons = 1;
1136 }
1137
1138
1139 //
1140 // Image options.
1141 //
1142 if (buttons) {
1143 XtVaCreateManagedWidget
1144 ("optionSeparator", xmSeparatorWidgetClass, pulldown, NULL);
1145 buttons = 0;
1146 }
1147
1148 if (this->saveImageCmd) {
1149 this->saveImageOption =
1150 new ButtonInterface(pulldown,
1151 "imageSaveImageOption", this->saveImageCmd);
1152 buttons = 1;
1153 }
1154
1155 if (this->printImageCmd) {
1156 this->printImageOption =
1157 new ButtonInterface(pulldown,
1158 "imagePrintImageOption", this->printImageCmd);
1159 buttons = 1;
1160 }
1161
1162
1163 //
1164 // Close/quite
1165 //
1166 if (buttons)
1167 XtVaCreateManagedWidget
1168 ("optionSeparator", xmSeparatorWidgetClass, pulldown, NULL);
1169
1170 #if 0
1171 if(!this->isAnchor())
1172 #endif
1173 this->closeOption =
1174 new ButtonInterface(pulldown,"imageCloseOption",this->closeCmd);
1175 #if 0
1176 else
1177 {
1178 this->quitOption =
1179 new ButtonInterface(pulldown,"imageQuitOption",theDXApplication->exitCmd);
1180 }
1181 #endif
1182
1183 XtAddCallback(pulldown,
1184 XmNmapCallback,
1185 (XtCallbackProc)ImageWindow_FileMenuMapCB,
1186 (XtPointer)this);
1187
1188 if ((theDXApplication->appAllowsExitOptions() && this->isAnchor()) ||
1189 theDXApplication->inDataViewerMode())
1190 {
1191 ASSERT(this->closeOption);
1192 if(this->network->saveToFileRequired())
1193 ((ButtonInterface*)this->closeOption)->setLabel("Quit...");
1194 else
1195 ((ButtonInterface*)this->closeOption)->setLabel("Quit");
1196 XmString accText = XmStringCreateSimple("Ctrl+Q");
1197 XtVaSetValues(this->closeOption->getRootWidget(),
1198 XmNmnemonic, XK_Q,
1199 XmNaccelerator, "Ctrl<Key>Q",
1200 XmNacceleratorText,accText,
1201 NULL);
1202 XmStringFree(accText);
1203 }
1204 else
1205 {
1206 ((ButtonInterface*)this->closeOption)->setLabel("Close");
1207 XmString accText = XmStringCreateSimple("Ctrl+W");
1208 XtVaSetValues(this->closeOption->getRootWidget(),
1209 XmNmnemonic, XK_C,
1210 XmNaccelerator, "Ctrl<Key>W",
1211 XmNacceleratorText,accText,
1212 NULL);
1213 XmStringFree(accText);
1214 }
1215
1216 if (!this->isAnchor())
1217 {
1218 if (this->openOption)
1219 this->openOption->deactivate();
1220 if (this->saveOption)
1221 this->saveOption->deactivate();
1222 if (this->saveAsOption)
1223 this->saveAsOption->deactivate();
1224 if (this->saveCfgOption)
1225 this->saveCfgOption->deactivate();
1226 if (this->openCfgOption)
1227 this->openCfgOption->deactivate();
1228 if (this->loadMacroOption)
1229 this->loadMacroOption->deactivate();
1230 if (this->loadMDFOption)
1231 this->loadMDFOption->deactivate();
1232 }
1233 }
1234
1235
createWindowsMenu(Widget parent)1236 void ImageWindow::createWindowsMenu(Widget parent)
1237 {
1238 ASSERT(parent);
1239
1240 Widget pulldown;
1241
1242 if (!theDXApplication->appAllowsWindowsMenus())
1243 return;
1244
1245 //
1246 // Create "Windows" menu and options.
1247 //
1248 pulldown =
1249 this->windowsMenuPulldown =
1250 XmCreatePulldownMenu
1251 (parent, "windowsMenuPulldown", NUL(ArgList), 0);
1252 this->windowsMenu =
1253 XtVaCreateManagedWidget
1254 ("windowsMenu",
1255 xmCascadeButtonWidgetClass,
1256 parent,
1257 XmNsubMenuId, pulldown,
1258 NULL);
1259
1260 if (theDXApplication->appAllowsEditorAccess())
1261 this->openVisualProgramEditorOption =
1262 new ButtonInterface
1263 (pulldown, "imageOpenVisualProgramEditorOption", this->openVPECmd);
1264
1265 if (theDXApplication->appAllowsPanelAccess()) {
1266 if (theDXApplication->appAllowsOpenAllPanels())
1267 this->openAllControlPanelsOption =
1268 new ButtonInterface
1269 (pulldown,
1270 "imageOpenAllControlPanelsOption",
1271 this->network->getOpenAllPanelsCommand());
1272
1273 this->openControlPanelByNameMenu =
1274 new CascadeMenu("imageOpenControlPanelByNameOption",pulldown);
1275
1276 // Builds the list of control panels
1277 XtAddCallback(pulldown,
1278 XmNmapCallback,
1279 (XtCallbackProc)ImageWindow_WindowsMenuMapCB,
1280 (XtPointer)this);
1281 }
1282
1283 this->openAllColormapEditorsOption =
1284 new ButtonInterface
1285 (pulldown, "imageOpenAllColormapEditorsOption",
1286 theDXApplication->openAllColormapCmd);
1287
1288 this->messageWindowOption =
1289 new ButtonInterface
1290 (pulldown, "imageMessageWindowOption",
1291 theDXApplication->messageWindowCmd);
1292
1293
1294 }
1295
ImageWindow_FileMenuMapCB(Widget,XtPointer,XtPointer)1296 extern "C" void ImageWindow_FileMenuMapCB(Widget ,
1297 XtPointer ,
1298 XtPointer )
1299 {
1300 //
1301 // Used to set the accelerator for quit. We may not need this
1302 // callback anymore.
1303 //
1304 }
1305
1306
ImageWindow_WindowsMenuMapCB(Widget w,XtPointer clientdata,XtPointer calldata)1307 extern "C" void ImageWindow_WindowsMenuMapCB(Widget w,
1308 XtPointer clientdata,
1309 XtPointer calldata)
1310 {
1311 PanelAccessManager *panelMgr;
1312 ImageWindow *iw = (ImageWindow*)clientdata;
1313
1314 if (iw->openControlPanelByNameMenu) {
1315 Network *network = iw->network;
1316 CascadeMenu *menu = iw->openControlPanelByNameMenu;
1317 if (!network) {
1318 menu->deactivate();
1319 } else {
1320 //
1321 // The ImageWindow uses it's associated Node's PanelManger if
1322 // it is activated. If not available or not activated, it uses
1323 // the Network's.
1324 //
1325 if (iw->node)
1326 panelMgr = ((DisplayNode*)iw->node)->getPanelManager();
1327 else
1328 panelMgr = NULL;
1329 if (!panelMgr || !panelMgr->isActivated())
1330 panelMgr = network->getPanelAccessManager();
1331 network->fillPanelCascade(menu, panelMgr);
1332 }
1333 }
1334
1335 }
1336
createOptionsMenu(Widget parent)1337 void ImageWindow::createOptionsMenu(Widget parent)
1338 {
1339 ASSERT(parent);
1340
1341 Widget pulldown;
1342
1343 //
1344 // Create "Options" menu and options.
1345 //
1346 pulldown =
1347 this->optionsMenuPulldown =
1348 XmCreatePulldownMenu
1349 (parent, "optionsMenuPulldown", NUL(ArgList), 0);
1350 this->optionsMenu =
1351 XtVaCreateManagedWidget
1352 ("optionsMenu",
1353 xmCascadeButtonWidgetClass,
1354 parent,
1355 XmNsubMenuId, pulldown,
1356 NULL);
1357
1358
1359 //
1360 // View Control
1361 //
1362
1363 this->viewControlOption =
1364 new ButtonInterface(pulldown, "imageViewControlOption",
1365 this->viewControlCmd);
1366
1367 ToggleButtonInterface *tbm;
1368 CascadeMenu *cmm = this->modeOptionCascade =
1369 new CascadeMenu("imageModeOption",pulldown);
1370
1371 Widget mitem_parent = cmm->getMenuItemParent();
1372
1373 ASSERT(this->modeNoneCmd);
1374 this->modeNoneOption = tbm = new ToggleButtonInterface(mitem_parent,
1375 "imageNoneOption", this->modeNoneCmd, TRUE);
1376 cmm->appendComponent(tbm);
1377
1378 ASSERT(this->modeCameraCmd);
1379 this->modeCameraOption = tbm = new ToggleButtonInterface(mitem_parent,
1380 "imageCameraOption", this->modeCameraCmd, FALSE);
1381 cmm->appendComponent(tbm);
1382
1383 ASSERT(this->modeCursorsCmd);
1384 this->modeCursorsOption = tbm = new ToggleButtonInterface(mitem_parent,
1385 "imageCursorsOption", this->modeCursorsCmd, FALSE);
1386 cmm->appendComponent(tbm);
1387
1388 ASSERT(this->modePickCmd);
1389 this->modePickOption = tbm = new ToggleButtonInterface(mitem_parent,
1390 "imagePickOption", this->modePickCmd, FALSE);
1391 cmm->appendComponent(tbm);
1392
1393 ASSERT(this->modeNavigateCmd);
1394 this->modeNavigateOption = tbm = new ToggleButtonInterface(mitem_parent,
1395 "imageNavigateOption", this->modeNavigateCmd, FALSE);
1396 cmm->appendComponent(tbm);
1397
1398 ASSERT(this->modePanZoomCmd);
1399 this->modePanZoomOption = tbm = new ToggleButtonInterface(mitem_parent,
1400 "imagePanZoomOption", this->modePanZoomCmd, FALSE);
1401 cmm->appendComponent(tbm);
1402
1403 ASSERT(this->modeRoamCmd);
1404 this->modeRoamOption = tbm = new ToggleButtonInterface(mitem_parent,
1405 "imageRoamOption", this->modeRoamCmd, FALSE);
1406 cmm->appendComponent(tbm);
1407
1408 ASSERT(this->modeRotateCmd);
1409 this->modeRotateOption = tbm = new ToggleButtonInterface(mitem_parent,
1410 "imageRotateOption", this->modeRotateCmd, FALSE);
1411 cmm->appendComponent(tbm);
1412
1413 ASSERT(this->modeZoomCmd);
1414 this->modeZoomOption = tbm = new ToggleButtonInterface(mitem_parent,
1415 "imageZoomOption", this->modeZoomCmd, FALSE);
1416 cmm->appendComponent(tbm);
1417
1418 XtVaCreateManagedWidget
1419 ("optionSeparator", xmSeparatorWidgetClass, pulldown, NULL);
1420
1421 this->undoOption =
1422 new ButtonInterface(pulldown, "imageUndoOption",
1423 this->undoCmd);
1424
1425 this->redoOption =
1426 new ButtonInterface(pulldown, "imageRedoOption",
1427 this->redoCmd);
1428
1429 this->resetOption =
1430 new ButtonInterface(pulldown, "imageResetOption",
1431 this->resetCmd);
1432
1433 //
1434 // Image options/modes
1435 //
1436 XtVaCreateManagedWidget
1437 ("optionSeparator", xmSeparatorWidgetClass, pulldown, NULL);
1438
1439 this->autoAxesOption =
1440 new ButtonInterface(pulldown, "imageAutoAxesOption",
1441 this->autoAxesCmd);
1442 this->backgroundColorOption =
1443 new ButtonInterface(pulldown, "imageBackgroundColorOption",
1444 this->backgroundColorCmd);
1445 this->displayRotationGlobeOption =
1446 new ToggleButtonInterface
1447 (pulldown, "imageDisplayRotationGlobeOption",
1448 this->displayRotationGlobeCmd, FALSE);
1449 //
1450 // Execution options/modes
1451 //
1452 XtVaCreateManagedWidget
1453 ("optionSeparator", xmSeparatorWidgetClass, pulldown, NULL);
1454
1455 this->renderingOptionsOption =
1456 new ButtonInterface(pulldown, "imageRenderingOptionsOption",
1457 this->renderingOptionsCmd);
1458
1459 if (!theDXApplication->appLimitsImageOptions()) {
1460 // 'Set the frame buffer depth' pulldown option.
1461
1462 ToggleButtonInterface *tbi;
1463 CascadeMenu *cm = this->imageDepthCascade =
1464 new CascadeMenu("imageSetImageDepthOption",pulldown);
1465
1466 Widget item_parent = cm->getMenuItemParent();
1467
1468 ASSERT(this->imageDepth8Cmd);
1469 this->imageDepth8Option = tbi = new ToggleButtonInterface(item_parent,
1470 "8", this->imageDepth8Cmd, FALSE);
1471 cm->appendComponent(tbi);
1472
1473 ASSERT(this->imageDepth12Cmd);
1474 this->imageDepth12Option = tbi = new ToggleButtonInterface(item_parent,
1475 "12", this->imageDepth12Cmd, FALSE);
1476 cm->appendComponent(tbi);
1477
1478 ASSERT(this->imageDepth15Cmd);
1479 this->imageDepth15Option = tbi = new ToggleButtonInterface(item_parent,
1480 "15", this->imageDepth15Cmd, FALSE);
1481 cm->appendComponent(tbi);
1482
1483 ASSERT(this->imageDepth16Cmd);
1484 this->imageDepth16Option = tbi = new ToggleButtonInterface(item_parent,
1485 "16", this->imageDepth16Cmd, FALSE);
1486 cm->appendComponent(tbi);
1487
1488 ASSERT(this->imageDepth24Cmd);
1489 this->imageDepth24Option = tbi = new ToggleButtonInterface(item_parent,
1490 "24", this->imageDepth24Cmd, FALSE);
1491 cm->appendComponent(tbi);
1492
1493 ASSERT(this->imageDepth32Cmd);
1494 this->imageDepth32Option = tbi = new ToggleButtonInterface(item_parent,
1495 "32", this->imageDepth32Cmd, FALSE);
1496 cm->appendComponent(tbi);
1497
1498 this->throttleOption =
1499 new ButtonInterface(pulldown, "imageThrottleOption",
1500 this->throttleCmd);
1501 }
1502
1503
1504 //
1505 // Miscellaneous options
1506 //
1507 if (!theDXApplication->appLimitsImageOptions()) {
1508 XtVaCreateManagedWidget
1509 ("optionSeparator", xmSeparatorWidgetClass, pulldown, NULL);
1510
1511 this->changeImageNameOption =
1512 new ButtonInterface(pulldown, "imageChangeImageNameOption",
1513 this->changeImageNameCmd);
1514
1515
1516 this->setPanelAccessOption =
1517 new ButtonInterface(pulldown, "imageSetPanelAccessOption",
1518 this->setPanelAccessCmd);
1519
1520 #if USE_STARTUP_OPTION
1521 XtVaCreateManagedWidget
1522 ("optionSeparator", xmSeparatorWidgetClass, pulldown, NULL);
1523
1524 this->addStartupToggleOption(pulldown);
1525 #endif
1526 }
1527
1528 }
1529
notify(const Symbol message,const void * msgdata,const char * msg)1530 void ImageWindow::notify(const Symbol message, const void *msgdata, const char *msg)
1531 {
1532 if (message == DXApplication::MsgPanelChanged) {
1533 //
1534 // Set the command activations that depend on the number of panels.
1535 //
1536 if (this->setPanelAccessCmd) {
1537 if(this->node AND (this->network->getPanelCount() > 0))
1538 this->setPanelAccessCmd->activate();
1539 else
1540 this->setPanelAccessCmd->deactivate();
1541 }
1542 }
1543 this->DXWindow::notify(message, msgdata, msg);
1544
1545 }
1546
createHelpMenu(Widget parent)1547 void ImageWindow::createHelpMenu(Widget parent)
1548 {
1549 ASSERT(parent);
1550
1551 this->DXWindow::createHelpMenu(parent);
1552
1553 XtVaCreateManagedWidget("separator", xmSeparatorWidgetClass,
1554 this->helpMenuPulldown,
1555 NULL);
1556
1557 this->onVisualProgramOption =
1558 new ButtonInterface(this->helpMenuPulldown,
1559 "imageOnVisualProgramOption",
1560 this->network->getHelpOnNetworkCommand());
1561 }
1562
1563
1564
createMenus(Widget parent)1565 void ImageWindow::createMenus(Widget parent)
1566 {
1567 ASSERT(parent);
1568
1569
1570 //
1571 // Create the menus.
1572 //
1573 this->createFileMenu(parent);
1574 this->createExecuteMenu(parent);
1575 this->createWindowsMenu(parent);
1576 this->createConnectionMenu(parent);
1577 this->createOptionsMenu(parent);
1578 this->createHelpMenu(parent);
1579
1580 //
1581 // Right justify the help menu (if it exists).
1582 //
1583 if (this->helpMenu)
1584 {
1585 XtVaSetValues(parent, XmNmenuHelpWidget, this->helpMenu, NULL);
1586 }
1587 }
1588
setDisplayGlobe()1589 void ImageWindow::setDisplayGlobe()
1590 {
1591 ((ToggleButtonInterface*)this->displayRotationGlobeOption)->toggleState();
1592 this->state.globeDisplayed = ((ToggleButtonInterface*)
1593 this->displayRotationGlobeOption)->getState();
1594
1595 if (this->state.hardwareRender)
1596 {
1597 long l = this->state.globeDisplayed;
1598 this->sendClientMessage(this->atoms.display_globe,l);
1599 }
1600 else
1601 XtVaSetValues(this->canvas,
1602 XmNdisplayGlobe,
1603 this->state.globeDisplayed,
1604 NULL);
1605 }
1606
1607 /*****************************************************************************/
1608 /* uinAssignDisplayString - */
1609 /* */
1610 /* */
1611 /*****************************************************************************/
getDisplayString()1612 char *ImageWindow::getDisplayString()
1613 {
1614 #if defined(HAVE_SYS_UTSNAME_H)
1615 struct
1616 utsname name;
1617 #else
1618 #define HOST_NAMELEN 33
1619 char *cp;
1620 struct _dummy_utsname
1621 {
1622 char nodename[HOST_NAMELEN];
1623 } name;
1624 #endif
1625 Window window;
1626 Window child;
1627 boolean frame_buffer;
1628 int x;
1629 int y;
1630 char* display;
1631 char host[64];
1632 char unit[16];
1633 static char string[512];
1634
1635 if (this->execute_after_resize_to) XtRemoveTimeOut (this->execute_after_resize_to);
1636 this->execute_after_resize_to = 0;
1637
1638 //
1639 // If there is a pending resize, then make sure it gets
1640 // processed first so that the proper WHERE param is sent.
1641 //
1642 if (this->hasPendingWindowPlacement()) {
1643 if (this->reset_eor_wp) XtRemoveWorkProc (this->reset_eor_wp);
1644 this->reset_eor_wp = 0;
1645 this->setGeometry(this->pending_resize_x, this->pending_resize_y,
1646 this->pending_resize_width, this->pending_resize_height);
1647 this->setExecuteOnResize(TRUE);
1648 }
1649
1650 /*
1651 * Determine whether we're working with a frame buffer or not....
1652 */
1653 window = XtWindow(this->getCanvas());
1654
1655 frame_buffer = this->state.frameBuffer;
1656
1657 DisplayNode *in = (DisplayNode *)this->node;
1658 /*
1659 * Determine the X server host.
1660 */
1661 display = DisplayString(theApplication->getDisplay());
1662 #if defined(DXD_WIN)
1663 /*
1664 as DISPLAY Enviroment is haveing some king of problen with EXCEED...
1665 if DISPLAY is set to be DXPENT:0 (which is hostname:o), DXUI startup
1666 gives an error "Unable to open CONNECT Strean". This problem is also
1667 encountered while running EXCEED samples also.
1668
1669 If it is set to be "localhost:o" than eEXEC fails in "gethostname()".
1670
1671 */
1672 #endif
1673 if (display)
1674 {
1675 #if defined(HAVE_SYS_UTSNAME_H)
1676 if (uname(&name) < 0)
1677 #else
1678 if (gethostname(name.nodename, HOST_NAMELEN) < 0)
1679 #endif
1680 {
1681 return NULL;
1682 }
1683 #if !defined(HAVE_SYS_UTSNAME_H)
1684 cp = strchr(name.nodename,'.');
1685 if (cp != NULL)
1686 {
1687 *cp = '\0';
1688 }
1689 #endif
1690 const char *serverHost;
1691 theDXApplication->getServerParameters(NULL, &serverHost,
1692 NULL, NULL, NULL, NULL, NULL);
1693 if (sscanf(display, "%[^:]:%s", host, unit) == 2)
1694 {
1695 const char* group_name =
1696 #if WORKSPACE_PAGES
1697 in->getGroupName(theSymbolManager->getSymbol(PROCESS_GROUP));
1698 #else
1699 in->getGroupName();
1700 #endif
1701 #ifdef DXD_OS_NON_UNIX
1702 if(!DXChild::HostIsLocal(serverHost))
1703 #else
1704 if (EqualString(host, "unix") &&
1705 (group_name != NULL ||
1706 !DXChild::HostIsLocal(serverHost)))
1707 #endif
1708 {
1709 display = new char[ STRLEN(name.nodename) + STRLEN(unit) + 4];
1710 SPRINTF(display, "%s:%s", name.nodename, unit);
1711 }
1712 else
1713 {
1714 display = DuplicateString(display);
1715 }
1716 }
1717 else if (sscanf(display, ":%s", unit) == 1)
1718 {
1719 const char* group_name =
1720 #if WORKSPACE_PAGES
1721 in->getGroupName(theSymbolManager->getSymbol(PROCESS_GROUP));
1722 #else
1723 in->getGroupName();
1724 #endif
1725 if (group_name != NULL || !DXChild::HostIsLocal(serverHost))
1726 {
1727
1728 display = new char[STRLEN(name.nodename) + STRLEN(unit) + 4];
1729 SPRINTF(display, "%s:%s", name.nodename, unit);
1730 }
1731 else
1732 {
1733 display = DuplicateString(display);
1734 }
1735 }
1736 else
1737 {
1738 return NULL;
1739 }
1740 }
1741 else
1742 {
1743 (void)gethostname(host, 63);
1744 #if defined(HAVE_SYS_UTSNAME_H)
1745 if (uname(&name) < 0)
1746 #else
1747 if (gethostname(name.nodename, HOST_NAMELEN) < 0)
1748 #endif
1749 {
1750 return NULL;
1751 }
1752 #if !defined(HAVE_SYS_UTSNAME_H)
1753 cp = strchr(name.nodename,'.');
1754 if (cp != NULL)
1755 {
1756 *cp = '\0';
1757 }
1758 #endif
1759
1760 display = new char[STRLEN(name.nodename) + STRLEN(unit) + 4];
1761 SPRINTF(display, "%s:0", name.nodename);
1762 }
1763
1764 /*
1765 * Compose the display string accordingly.
1766 */
1767 if (!frame_buffer)
1768 {
1769 SPRINTF(string, "X%d,%s,##%ld",
1770 in->getDepth(), display, window);
1771 }
1772 else
1773 {
1774 XTranslateCoordinates
1775 (XtDisplay(this->getCanvas()),
1776 XtWindow(this->getCanvas()),
1777 RootWindowOfScreen(XtScreen(this->getCanvas())),
1778 0, 0,
1779 &x, &y,
1780 &child);
1781
1782 #ifdef FB_FLAG
1783 unsigned int flag = 0x00000000;
1784 if(in->isLastImage())
1785 flag |= FB_WHERE_SWAP;
1786
1787 SPRINTF(string,
1788 "FB,%s,%d,%d,##%d,%#010x",
1789 display,
1790 (in->isLastImage() ? x : -(1 + x)),
1791 y,
1792 window,
1793 flag);
1794 #endif
1795 SPRINTF(string,
1796 "FB,%s,%d,%d,##%ld",
1797 display,
1798 (in->isLastImage() ? x : -(1 + x)),
1799 y,
1800 window);
1801 }
1802 delete display;
1803
1804 return string;
1805 }
ImageWindow_RedrawCB(Widget drawingArea,XtPointer clientData,XtPointer callData)1806 extern "C" void ImageWindow_RedrawCB(Widget drawingArea,
1807 XtPointer clientData,
1808 XtPointer callData)
1809 {
1810 XmPictureCallbackStruct *pictureData =(XmPictureCallbackStruct*)callData;
1811 XEvent *event = pictureData->event;
1812 ImageWindow *obj = (ImageWindow*) clientData;
1813
1814 Atom actual_type;
1815 int actual_format;
1816 unsigned long n_items;
1817 unsigned long bytes_after;
1818 Pixmap *pixmap;
1819
1820 /*
1821 * Get the pixmap id from the window property list each time
1822 * in case the pixmap has been changed by the SVS server.
1823 */
1824 XGetWindowProperty
1825 (XtDisplay(drawingArea),
1826 event->xexpose.window,
1827 obj->atoms.dx_pixmap_id,
1828 0,
1829 1,
1830 FALSE,
1831 XA_PIXMAP,
1832 &actual_type,
1833 &actual_format,
1834 &n_items,
1835 &bytes_after,
1836 (unsigned char**)&pixmap);
1837
1838 /*
1839 * Draw the image if we have a pixmap to use...
1840 */
1841 if (actual_type != None)
1842 {
1843 obj->state.pixmap = *pixmap;
1844
1845 if(!obj->state.gc)
1846 {
1847 //
1848 // Create Graphics Context
1849 //
1850 obj->state.gc = XCreateGC
1851 (XtDisplay(obj->getCanvas()),
1852 XtWindow(obj->getCanvas()),
1853 NUL(long),
1854 NUL(XGCValues*));
1855 Pixel bg;
1856 XtVaGetValues(obj->getCanvas(), XmNbackground, &bg, NULL);
1857 XSetForeground(XtDisplay(obj->getCanvas()), obj->state.gc, bg);
1858 }
1859
1860 XCopyArea
1861 (XtDisplay(drawingArea),
1862 obj->state.pixmap,
1863 XtWindow(obj->getCanvas()),
1864 obj->state.gc,
1865 0, 0,
1866 obj->state.width,
1867 obj->state.height,
1868 0, 0);
1869 Dimension wwidth, wheight;
1870 XtVaGetValues(obj->getCanvas(),
1871 XmNwidth, &wwidth,
1872 XmNheight, &wheight,
1873 NULL);
1874 if (wwidth > obj->state.width)
1875 {
1876 XFillRectangle(XtDisplay(obj->getCanvas()),
1877 XtWindow(obj->getCanvas()),
1878 obj->state.gc,
1879 obj->state.width, 0,
1880 wwidth - obj->state.width, wheight);
1881 }
1882 if (wheight > obj->state.height)
1883 {
1884 XFillRectangle(XtDisplay(obj->getCanvas()),
1885 XtWindow(obj->getCanvas()),
1886 obj->state.gc,
1887 0, obj->state.height,
1888 obj->state.width, wheight - obj->state.height);
1889 }
1890
1891
1892 XFlush(XtDisplay(drawingArea));
1893 XtVaSetValues(obj->getCanvas(),
1894 XmNpicturePixmap, obj->state.pixmap, NULL);
1895 XFree((char*)pixmap);
1896 }
1897 else
1898 {
1899 XClearWindow(XtDisplay(drawingArea), XtWindow(drawingArea));
1900 }
1901 }
ImageWindow_ZoomCB(Widget drawingArea,XtPointer clientData,XtPointer callData)1902 extern "C" void ImageWindow_ZoomCB(Widget drawingArea,
1903 XtPointer clientData,
1904 XtPointer callData)
1905 {
1906 ((ImageWindow*)clientData)->zoomImage((XmPictureCallbackStruct*)callData);
1907
1908 }
1909
zoomImage(XmPictureCallbackStruct * pictureData)1910 void ImageWindow::zoomImage(XmPictureCallbackStruct* pictureData)
1911 {
1912 boolean execOnChange = theDXApplication->getExecCtl()->inExecOnChange();
1913
1914
1915 /*
1916 * NOP if we have not recieved an image from the server.
1917 */
1918 if (this->state.pixmap == NUL(Pixmap))
1919 {
1920 return;
1921 }
1922
1923 ImageNode *in = (ImageNode *)this->node;
1924
1925 if(pictureData->projection == 0)
1926 {
1927 double w;
1928 in->getWidth(w);
1929 w *= pictureData->zoom_factor;
1930 in->setWidth(w, FALSE);
1931 }
1932 else if(pictureData->projection == 1)
1933 {
1934 in->setViewAngle(pictureData->view_angle, FALSE);
1935 }
1936
1937 double v[3];
1938 v[0] = pictureData->x;
1939 v[1] = pictureData->y;
1940 v[2] = pictureData->z;
1941 in->setTo(v, FALSE);
1942 v[0] = pictureData->from_x;
1943 v[1] = pictureData->from_y;
1944 v[2] = pictureData->from_z;
1945 in->setFrom(v, TRUE);
1946
1947 if (!execOnChange)
1948 theDXApplication->getExecCtl()->executeOnce();
1949 }
1950
ImageWindow_RoamCB(Widget drawingArea,XtPointer clientData,XtPointer callData)1951 extern "C" void ImageWindow_RoamCB(Widget drawingArea,
1952 XtPointer clientData,
1953 XtPointer callData)
1954 {
1955 ((ImageWindow*)clientData)->roamImage((XmPictureCallbackStruct*)callData);
1956 }
1957
roamImage(XmPictureCallbackStruct * calldata)1958 void ImageWindow::roamImage(XmPictureCallbackStruct* calldata)
1959 {
1960 double v[3];
1961 ViewControlDialog *viewCtl = this->viewControlDialog;
1962 ImageCamera *camera = &this->state.hardwareCamera;
1963 ImageNode *in = (ImageNode *)this->node;
1964 boolean execOnChange = theDXApplication->getExecCtl()->inExecOnChange();
1965
1966
1967 if (calldata->reason != XmPCR_MOVE)
1968 {
1969 return;
1970 }
1971
1972 if (this->state.pixmap == NUL(Pixmap))
1973 {
1974 return;
1975 }
1976
1977 if(viewCtl)
1978 viewCtl->resetSetView();
1979
1980 in->getFrom(camera->from);
1981 in->getTo(camera->to);
1982
1983 v[0] = calldata->x;
1984 v[1] = calldata->y;
1985 v[2] = calldata->z;
1986 in->setTo(v, FALSE);
1987
1988 if(NOT this->getPerspective())
1989 {
1990 v[0] = calldata->x + camera->from[0] - camera->to[0];
1991 v[1] = calldata->y + camera->from[1] - camera->to[1];
1992 v[2] = calldata->z + camera->from[2] - camera->to[2];
1993 }
1994 else
1995 in->getFrom(v);
1996
1997 in->setFrom(v, TRUE);
1998
1999 if (!execOnChange)
2000 theDXApplication->getExecCtl()->executeOnce();
2001 }
2002
ImageWindow_NavigateCB(Widget drawingArea,XtPointer clientData,XtPointer callData)2003 extern "C" void ImageWindow_NavigateCB(Widget drawingArea,
2004 XtPointer clientData,
2005 XtPointer callData)
2006 {
2007 ((ImageWindow*)clientData)->navigateImage((XmPictureCallbackStruct*)callData);
2008
2009 }
2010
navigateImage(XmPictureCallbackStruct * pictureData)2011 void ImageWindow::navigateImage(XmPictureCallbackStruct* pictureData)
2012 {
2013 ImageNode *in = (ImageNode *)this->node;
2014
2015 if (pictureData->reason == XmPCR_SELECT)
2016 {
2017 in->setButtonUp(FALSE, FALSE);
2018 }
2019
2020 if (pictureData->reason == XmPCR_DRAG ||
2021 pictureData->reason == XmPCR_SELECT)
2022 {
2023 /*
2024 * Update the Set View option menu to "None"
2025 */
2026 if (this->viewControlDialog)
2027 this->viewControlDialog->resetSetView();
2028
2029 // Stuff to do the first time.
2030 if (pictureData->reason == XmPCR_SELECT)
2031 {
2032 /*
2033 * Update the option menu to indicate we are in perspective.
2034 * The autocamera param assignment happens in _uipNavigateImage.
2035 */
2036 boolean p;
2037 in->getProjection(p);
2038 if (!p)
2039 {
2040 in->setProjection(TRUE, FALSE);
2041 if (this->viewControlDialog)
2042 this->viewControlDialog->resetProjection();
2043 }
2044 }
2045
2046 double v[3];
2047 v[0] = pictureData->x;
2048 v[1] = pictureData->y;
2049 v[2] = pictureData->z;
2050 in->setTo(v, FALSE);
2051 v[0] = pictureData->up_x;
2052 v[1] = pictureData->up_y;
2053 v[2] = pictureData->up_z;
2054 in->setUp(v, FALSE);
2055 v[0] = pictureData->from_x;
2056 v[1] = pictureData->from_y;
2057 v[2] = pictureData->from_z;
2058 in->setFrom(v, TRUE);
2059
2060 theDXApplication->getExecCtl()->enableExecOnChange();
2061 }
2062 else if (pictureData->reason == XmPCR_TRANSLATE_SPEED)
2063 {
2064 this->setTranslateSpeed(pictureData->translate_speed);
2065 }
2066 else if (pictureData->reason == XmPCR_ROTATE_SPEED)
2067 {
2068 this->setRotateSpeed(pictureData->rotate_speed);
2069 }
2070 if (pictureData->reason == XmPCR_MOVE)
2071 {
2072 in->setButtonUp(TRUE);
2073 }
2074 }
2075
ImageWindow_RotationCB(Widget drawingArea,XtPointer clientData,XtPointer callData)2076 extern "C" void ImageWindow_RotationCB(Widget drawingArea,
2077 XtPointer clientData,
2078 XtPointer callData)
2079 {
2080 ((ImageWindow*)clientData)->rotateImage((XmPictureCallbackStruct*)callData);
2081
2082 }
2083
rotateImage(XmPictureCallbackStruct * pictureData)2084 void ImageWindow::rotateImage(XmPictureCallbackStruct* pictureData)
2085 {
2086 boolean execOnChange = theDXApplication->getExecCtl()->inExecOnChange();
2087
2088 /*
2089 * NOP if we have not recieved an image from the server.
2090 */
2091 if (this->state.pixmap == NUL(Pixmap) || !this->directInteractionAllowed())
2092 {
2093 return;
2094 }
2095
2096 if ( ((pictureData->reason == XmPCR_DRAG) ||
2097 (pictureData->reason == XmPCR_SELECT)) &&
2098 !execOnChange)
2099 return;
2100
2101 ImageNode *in = (ImageNode*)this->node;
2102
2103 if (pictureData->reason == XmPCR_SELECT)
2104 {
2105 double v[3];
2106 in->getFrom(v);
2107 in->setButtonUp(FALSE, TRUE);
2108 return;
2109 }
2110
2111 /*
2112 * Update the Set View option menu to "None"
2113 */
2114 if (this->viewControlDialog)
2115 {
2116 this->viewControlDialog->resetSetView();
2117 this->viewControlDialog->resetLookDirection();
2118 }
2119
2120 if (pictureData->reason == XmPCR_MOVE)
2121 in->setButtonUp(TRUE, FALSE);
2122
2123 double v[3];
2124 v[0] = pictureData->from_x;
2125 v[1] = pictureData->from_y;
2126 v[2] = pictureData->from_z;
2127 in->setFrom(v, FALSE);
2128 v[0] = pictureData->up_x;
2129 v[1] = pictureData->up_y;
2130 v[2] = pictureData->up_z;
2131 in->setUp(v, TRUE);
2132
2133 if (!execOnChange)
2134 theDXApplication->getExecCtl()->executeOnce();
2135 }
ImageWindow_CursorCB(Widget drawingArea,XtPointer clientData,XtPointer callData)2136 extern "C" void ImageWindow_CursorCB(Widget drawingArea,
2137 XtPointer clientData,
2138 XtPointer callData)
2139 {
2140 XmPictureCallbackStruct *pictureData =(XmPictureCallbackStruct*)callData;
2141 ImageWindow *image = (ImageWindow*) clientData;
2142
2143 image->handleCursor(pictureData->reason, pictureData->cursor_num,
2144 pictureData->x, pictureData->y, pictureData->z);
2145 }
2146
handleCursor(int reason,int cursor_num,double x,double y,double z)2147 void ImageWindow::handleCursor(int reason, int cursor_num,
2148 double x, double y, double z)
2149 {
2150 if(NOT this->state.hardwareRender AND this->state.pixmap == 0)
2151 return;
2152
2153 ASSERT(this->currentProbeInstance > 0);
2154 ProbeNode* probe = (ProbeNode*)this->network->getNode("Probe",
2155 this->currentProbeInstance);
2156 if (!probe)
2157 probe = (ProbeNode*)this->network->getNode("ProbeList",
2158 this->currentProbeInstance);
2159 ASSERT(probe);
2160
2161 Parameter* param = probe->getOutput();
2162 long l[5];
2163
2164
2165 ImageNode *in = (ImageNode*)this->node;
2166
2167 switch(reason)
2168 {
2169 case XmPCR_SELECT:
2170 in->setButtonUp(FALSE, TRUE);
2171 break;
2172
2173 case XmPCR_CREATE:
2174 if(EqualString(probe->getNameString(),"Probe")
2175 AND param->hasValue())
2176 {
2177 if(NOT this->state.hardwareRender)
2178 XmPictureDeleteCursors((XmPictureWidget)this->canvas,
2179 cursor_num);
2180 else
2181 {
2182 l[0] = cursor_num;
2183 l[1] = XmPCR_DELETE;
2184 this->sendClientMessage(this->atoms.cursor_change, 2, l);
2185 }
2186 XmPictureResetCursor((XmPictureWidget)this->canvas);
2187 ErrorMessage("The maximum number of cursors for a probe is 1");
2188 }
2189 else
2190 {
2191 if(STRLEN(probe->getOutputValueString(1))+100 > UI_YYLMAX)
2192 {
2193 if(NOT this->state.hardwareRender)
2194 XmPictureDeleteCursors((XmPictureWidget)this->canvas,
2195 cursor_num);
2196 else
2197 {
2198 l[0] = cursor_num;
2199 l[1] = XmPCR_DELETE;
2200 this->sendClientMessage(this->atoms.cursor_change, 2, l);
2201 }
2202 XmPictureResetCursor((XmPictureWidget)this->canvas);
2203 ErrorMessage("Sorry, you can't add more probes in this probe list.");
2204 }
2205 else
2206 //
2207 // c1wright50
2208 // use -1 in software mode because (hack) there will always be
2209 // a motionnotify event to follow, but not in hardware mode.
2210 if (this->state.hardwareRender)
2211 probe->setCursorValue(cursor_num, x, y, z);
2212 else
2213 probe->setCursorValue(-1, x, y, z);
2214 }
2215 break;
2216
2217 case XmPCR_DRAG:
2218 probe->setCursorValue(cursor_num, x, y, z);
2219 break;
2220
2221 case XmPCR_MOVE:
2222 in->setButtonUp(TRUE, TRUE);
2223 probe->setCursorValue(cursor_num, x, y, z);
2224 break;
2225
2226 case XmPCR_DELETE:
2227 probe->deleteCursor(cursor_num);
2228 break;
2229
2230 default:
2231 ASSERT(False);
2232 }
2233 }
ImageWindow_PickCB(Widget drawingArea,XtPointer clientData,XtPointer callData)2234 extern "C" void ImageWindow_PickCB(Widget drawingArea,
2235 XtPointer clientData,
2236 XtPointer callData)
2237 {
2238 XmPictureCallbackStruct *pictureData =(XmPictureCallbackStruct*)callData;
2239 ImageWindow *image = (ImageWindow*) clientData;
2240
2241 image->pickImage(pictureData->x, pictureData->y);
2242 }
2243
pickImage(double x,double y)2244 void ImageWindow::pickImage(double x, double y)
2245 {
2246 if (!this->node->isA(ClassImageNode) ||
2247 this->getInteractionMode() != PICK)
2248 return;
2249
2250 if (this->currentPickInstance > 0) {
2251 PickNode *p = this->getCurrentPickNode();
2252 p->setCursorValue(-1, x, y, 0.0);
2253 }
2254 }
2255
ImageWindow_ModeCB(Widget drawingArea,XtPointer clientData,XtPointer callData)2256 extern "C" void ImageWindow_ModeCB(Widget drawingArea,
2257 XtPointer clientData,
2258 XtPointer callData)
2259 {
2260 XmPictureCallbackStruct *pictureData =(XmPictureCallbackStruct*)callData;
2261 ImageWindow *obj = (ImageWindow*) clientData;
2262
2263 if (NOT XtIsRealized(drawingArea) ||
2264 !obj->directInteractionAllowed())
2265 {
2266 return;
2267 }
2268
2269 obj->handleMode(pictureData);
2270 }
2271
handleMode(XmPictureCallbackStruct * pictureData)2272 void ImageWindow::handleMode(XmPictureCallbackStruct *pictureData)
2273 {
2274 switch (pictureData->mode) {
2275 case XmROAM_MODE:
2276 if (this->modeRoamCmd->isActive())
2277 this->modeRoamCmd->execute();
2278 break;
2279 case XmCURSOR_MODE:
2280 if (this->modeCursorsCmd->isActive())
2281 this->modeCursorsCmd->execute();
2282 break;
2283 case XmPICK_MODE:
2284 if (this->modePickCmd->isActive())
2285 this->modePickCmd->execute();
2286 break;
2287 case XmROTATION_MODE:
2288 if (this->modeRotateCmd->isActive())
2289 this->modeRotateCmd->execute();
2290 break;
2291 case XmZOOM_MODE:
2292 if (this->modeZoomCmd->isActive())
2293 this->modeZoomCmd->execute();
2294 break;
2295 case XmPANZOOM_MODE:
2296 if (this->modePanZoomCmd->isActive())
2297 this->modePanZoomCmd->execute();
2298 break;
2299 case XmNAVIGATE_MODE:
2300 if (this->modeNavigateCmd->isActive())
2301 this->modeNavigateCmd->execute();
2302 break;
2303 default:
2304 ASSERT(FALSE);
2305 }
2306 }
2307
ImageWindow_KeyCB(Widget drawingArea,XtPointer clientData,XtPointer callData)2308 extern "C" void ImageWindow_KeyCB(Widget drawingArea,
2309 XtPointer clientData,
2310 XtPointer callData)
2311 {
2312 XmPictureCallbackStruct *pictureData =(XmPictureCallbackStruct*)callData;
2313 ImageWindow *obj = (ImageWindow*) clientData;
2314
2315
2316 if (NOT XtIsRealized(drawingArea) ||
2317 !obj->directInteractionAllowed())
2318 {
2319 return;
2320 }
2321
2322 obj->handleKey(pictureData);
2323 }
2324
handleKey(XmPictureCallbackStruct * pictureData)2325 void ImageWindow::handleKey(XmPictureCallbackStruct *pictureData)
2326 {
2327 switch (pictureData->keysym) {
2328 case XK_k:
2329 case XK_K:
2330 if (this->modeCameraCmd->isActive())
2331 this->modeCameraCmd->execute();
2332 this->postViewControlDialog();
2333 break;
2334
2335 case XK_f:
2336 case XK_F:
2337 if (this->resetCmd->isActive())
2338 this->resetCmd->execute();
2339 break;
2340
2341 default:
2342 ASSERT(FALSE);
2343 }
2344 }
ImageWindow_UndoCB(Widget drawingArea,XtPointer clientData,XtPointer callData)2345 extern "C" void ImageWindow_UndoCB(Widget drawingArea,
2346 XtPointer clientData,
2347 XtPointer callData)
2348 {
2349 ImageWindow *obj = (ImageWindow*) clientData;
2350
2351 obj->undoCamera();
2352 }
2353
ImageWindow_ResizeCB(Widget drawingArea,XtPointer clientData,XtPointer callData)2354 extern "C" void ImageWindow_ResizeCB(Widget drawingArea,
2355 XtPointer clientData,
2356 XtPointer callData)
2357 {
2358 ImageWindow* iw = (ImageWindow*)clientData;
2359
2360 // Without this check, the resize event will cause an execution if
2361 // the image window is being managed for the 1st time ever.
2362 if (!iw->isManaged()) return ;
2363
2364 //
2365 // We used to proceed with this->imageResize() in response to a resize
2366 // event. Now we pause for a short time in order to wait for more
2367 // resize events to arrive. The length of the pause - well it's a hack
2368 // really - is arbitrary. This problem this is intended to work around
2369 // is the excessive amount of executing that's requested when displaying
2370 // on a redhat or like system whose window manage resizes windows
2371 // immediately rather than rubberbanding the new size the way Mwm always
2372 // used to.
2373 //
2374 if (iw->execute_after_resize_to)
2375 XtRemoveTimeOut (iw->execute_after_resize_to);
2376 XtAppContext apcxt = theApplication->getApplicationContext();
2377 iw->execute_after_resize_to = XtAppAddTimeOut (apcxt, 500, (XtTimerCallbackProc)
2378 ImageWindow_ResizeTO, (XtPointer)iw);
2379 }
2380
ImageWindow_ResizeTO(XtPointer clientData,XtIntervalId *)2381 extern "C" void ImageWindow_ResizeTO (XtPointer clientData, XtIntervalId* )
2382 {
2383 ImageWindow* iw = (ImageWindow*)clientData;
2384 iw->execute_after_resize_to = 0;
2385 iw->resizeImage();
2386
2387 if(iw->printImageDialog AND iw->printImageDialog->isManaged())
2388 iw->printImageDialog->update();
2389 if(iw->saveImageDialog AND iw->saveImageDialog->isManaged())
2390 iw->saveImageDialog->update();
2391 }
2392
2393 //
2394 // The XmPictureCallbackStruct may be NULL
2395 //
resizeImage(boolean ok_to_send)2396 void ImageWindow::resizeImage(boolean ok_to_send)
2397 {
2398 boolean execOnChange = theDXApplication->getExecCtl()->inExecOnChange();
2399 Widget canvas = this->getCanvas();
2400
2401 //
2402 // If we were called because the server changed the size.
2403 // do not restart an execution sequence OR
2404 // If this window is not associated with an Image node,
2405 // ignore this request.
2406 //
2407 if (this->node == NUL(Node*)) return ;
2408 if (this->node->isA(ClassImageNode) == FALSE) return ;
2409 if (this->state.resizeFromServer) return ;
2410
2411 ImageNode *in = (ImageNode *)this->node;
2412
2413 //
2414 // Otherwise, get the new width and height.
2415 // Dimensions are sometimes 0 when the window is being created and
2416 // initial geometry negotiation is going on.
2417 //
2418 Dimension width, height;
2419 XtVaGetValues(canvas, XmNwidth, &width, XmNheight, &height, NULL);
2420 if (width > 0) {
2421 in->setResolution(width, height, FALSE);
2422 double aspect = (height + 0.5) / width;
2423 if (ok_to_send) {
2424 in->setAspect(aspect, this->isManaged());
2425
2426 //
2427 // Prevent an execution if the image window is unmanaged.
2428 //
2429 boolean force = ((this->isExecuteOnResize()) && (!execOnChange));
2430 if ((this->isManaged()) && (force))
2431 theDXApplication->getExecCtl()->executeOnce();
2432
2433 if (this->viewControlDialog && this->directInteractionAllowed())
2434 this->viewControlDialog->setSensitivity(in->useVector());
2435 } else {
2436 in->setAspect(aspect, FALSE);
2437 }
2438 }
2439 }
2440
ImageWindow_PropertyNotifyCB(Widget imageWindow,XtPointer clientData,XtPointer callData)2441 void ImageWindow_PropertyNotifyCB(Widget imageWindow,
2442 XtPointer clientData,
2443 XtPointer callData)
2444 {
2445 XmPictureCallbackStruct *pictureData =(XmPictureCallbackStruct*)callData;
2446 XEvent *event = pictureData->event;
2447 XEvent e;
2448 ImageWindow *obj = (ImageWindow*) clientData;
2449 Atom required_type;
2450 Atom actual_type;
2451 int actual_format;
2452 unsigned long n_items;
2453 unsigned long bytes_after;
2454 Window *window;
2455 Widget shell;
2456 XWindowAttributes attributes;
2457 Boolean iconic;
2458
2459 if(event->xproperty.state == PropertyDelete)
2460 return;
2461
2462 required_type = XInternAtom(XtDisplay(imageWindow), "GL_WINDOW_ID", False);
2463 if(required_type != event->xproperty.atom)
2464 {
2465 // If the property is not for GL rendering, return.
2466 return;
2467 }
2468
2469 //
2470 // Determine if we are iconified
2471 //
2472 if(!obj->isManaged())
2473 {
2474 iconic = False;
2475 }
2476 else
2477 {
2478 shell = imageWindow;
2479 while(!XtIsShell(shell)) shell = XtParent(shell);
2480
2481 XGetWindowAttributes(XtDisplay(imageWindow),
2482 XtWindow(shell),
2483 &attributes);
2484 if(attributes.map_state == IsUnmapped)
2485 iconic = True;
2486 else
2487 iconic = False;
2488 }
2489
2490 if(XGetWindowProperty
2491 (XtDisplay(imageWindow),
2492 event->xproperty.window,
2493 event->xproperty.atom,
2494 0,
2495 1,
2496 FALSE,
2497 required_type,
2498 &actual_type,
2499 &actual_format,
2500 &n_items,
2501 &bytes_after,
2502 (unsigned char**)&window) != Success)
2503 {
2504 WarningMessage("XGetWindowProperty failed in (XtCallbackProc)ImageWindow_PropertyNotifyCB");
2505 return;
2506 }
2507
2508 if(actual_type != required_type)
2509 {
2510 // This case happens when the property is destroyed.
2511 XFree(window);
2512 return;
2513 }
2514
2515 if(!iconic)
2516 {
2517 // Ask for Map Events
2518 XSelectInput(XtDisplay(imageWindow),
2519 *window,
2520 StructureNotifyMask);
2521
2522 obj->manage();
2523
2524 // Map it for the exec
2525 XMapWindow(XtDisplay(imageWindow), *window);
2526
2527 // Make sure we are inited to something other than MapNotify
2528 e.type = MapNotify - 1;
2529
2530 // Wait for the map event
2531 while(e.type != MapNotify)
2532 XWindowEvent(XtDisplay(imageWindow),
2533 *window,
2534 StructureNotifyMask,
2535 &e);
2536 }
2537
2538 // This is the signal to the exec that the window has been mapped
2539 XDeleteProperty
2540 (XtDisplay(imageWindow),
2541 event->xproperty.window,
2542 event->xproperty.atom);
2543
2544 XFree(window);
2545 }
ImageWindow_ClientMessageCB(Widget imageWindow,XtPointer clientData,XtPointer callData)2546 void ImageWindow_ClientMessageCB(Widget imageWindow,
2547 XtPointer clientData,
2548 XtPointer callData)
2549 {
2550 XmPictureCallbackStruct *pictureData =(XmPictureCallbackStruct*)callData;
2551 XEvent *event = pictureData->event;
2552 ImageWindow *obj = (ImageWindow*) clientData;
2553 ImageNode *in = (ImageNode*)obj->node;
2554 Dimension width;
2555 Dimension height;
2556
2557 //
2558 // Don't access in if it is not an image node.
2559 //
2560 if(!obj->node->isA(ClassImageNode)) in = NULL;
2561
2562 if(event->xclient.message_type == obj->atoms.gl_shutdown)
2563 {
2564 obj->state.hardwareRender = False;
2565 obj->state.hardwareRenderExists = False;
2566 }
2567 else if (event->xclient.message_type == obj->atoms.from_vector)
2568 {
2569 float temp;
2570 memcpy(&temp, &event->xclient.data.l[0], sizeof(float));
2571 obj->state.hardwareCamera.from[0] = (double)temp;
2572 memcpy(&temp, &event->xclient.data.l[1], sizeof(float));
2573 obj->state.hardwareCamera.from[1] = (double)temp;
2574 memcpy(&temp, &event->xclient.data.l[2], sizeof(float));
2575 obj->state.hardwareCamera.from[2] = (double)temp;
2576 }
2577 else if (event->xclient.message_type == obj->atoms.motion)
2578 {
2579 int itemp;
2580 memcpy(&itemp, &event->xclient.data.l[0], sizeof(int));
2581 XtVaSetValues(obj->getCanvas(),
2582 XmNtranslateSpeed, itemp,
2583 NULL);
2584 if (obj->viewControlDialog)
2585 obj->viewControlDialog->setNavigateSpeed(itemp);
2586 }
2587 else if (event->xclient.message_type == obj->atoms.pivot)
2588 {
2589 int itemp;
2590 memcpy(&itemp, &event->xclient.data.l[0], sizeof(int));
2591 XtVaSetValues(obj->getCanvas(),
2592 XmNrotateSpeed, itemp,
2593 NULL);
2594 if (obj->viewControlDialog)
2595 obj->viewControlDialog->setNavigatePivot(itemp);
2596 }
2597 else if (event->xclient.message_type == obj->atoms.undoable)
2598 {
2599 obj->state.hardwareCamera.undoable = (boolean)event->xclient.data.l[0];
2600 if (obj->state.hardwareCamera.undoable)
2601 obj->undoCmd->activate();
2602 else
2603 obj->undoCmd->deactivate();
2604 }
2605 else if (event->xclient.message_type == obj->atoms.redoable)
2606 {
2607 obj->state.hardwareCamera.redoable = (boolean)event->xclient.data.l[0];
2608 if (obj->state.hardwareCamera.redoable)
2609 obj->redoCmd->activate();
2610 else
2611 obj->redoCmd->deactivate();
2612 }
2613 else if (event->xclient.message_type == obj->atoms.up_vector)
2614 {
2615 /*
2616 * NOP if we have not recieved an image from gl.
2617 */
2618 if (obj->state.hardwareWindow == NUL(Window) ||
2619 !obj->directInteractionAllowed())
2620 {
2621 return;
2622 }
2623 double v[3];
2624 float temp;
2625
2626 memcpy(&temp, &event->xclient.data.l[0], sizeof(float));
2627 v[0] = (double)temp;
2628 memcpy(&temp, &event->xclient.data.l[1], sizeof(float));
2629 v[1] = (double)temp;
2630 memcpy(&temp, &event->xclient.data.l[2], sizeof(float));
2631 v[2] = (double)temp;
2632
2633 if(in)
2634 {
2635 in->setFrom(obj->state.hardwareCamera.from, FALSE);
2636 in->setUp(v);
2637 }
2638
2639 boolean execOnChange = theDXApplication->getExecCtl()->inExecOnChange();
2640 if (!execOnChange)
2641 theDXApplication->getExecCtl()->executeOnce();
2642 }
2643
2644 /*
2645 * Roam message from GL:
2646 */
2647 else if (event->xclient.message_type == obj->atoms.roam)
2648 {
2649 /*
2650 * NOP if we have not recieved an image from the server.
2651 */
2652 if (obj->state.hardwareWindow == NUL(Window) ||
2653 !obj->directInteractionAllowed())
2654 {
2655 return;
2656 }
2657
2658 float x, y, z;
2659 memcpy(&x, &event->xclient.data.l[0], sizeof(float));
2660 memcpy(&y, &event->xclient.data.l[1], sizeof(float));
2661 memcpy(&z, &event->xclient.data.l[2], sizeof(float));
2662
2663
2664 if (obj->state.hardwareCamera.projection == 0)
2665 {
2666 double from[3];
2667 double dir_x, dir_y, dir_z;
2668 dir_x = obj->state.hardwareCamera.from[0] -
2669 obj->state.hardwareCamera.to[0];
2670 dir_y = obj->state.hardwareCamera.from[1] -
2671 obj->state.hardwareCamera.to[1];
2672 dir_z = obj->state.hardwareCamera.from[2] -
2673 obj->state.hardwareCamera.to[2];
2674 if(in)
2675 {
2676 from[0] = dir_x + x;
2677 from[1] = dir_y + y;
2678 from[2] = dir_z + z;
2679 in->setFrom(from, FALSE);
2680 }
2681 }
2682
2683 if(in)
2684 {
2685 double to[3];
2686 to[0] = x;
2687 to[1] = y;
2688 to[2] = z;
2689 in->setTo(to, TRUE);
2690 }
2691
2692 boolean execOnChange = theDXApplication->getExecCtl()->inExecOnChange();
2693 if (!execOnChange)
2694 theDXApplication->getExecCtl()->executeOnce();
2695 }
2696
2697 /*
2698 * Zoom1 message from GL:
2699 */
2700 else if (event->xclient.message_type == obj->atoms.zoom1)
2701 {
2702 /*
2703 * NOP if we have not recieved an image from the server.
2704 */
2705 if (obj->state.hardwareWindow == NUL(Window) ||
2706 !obj->directInteractionAllowed())
2707 {
2708 return;
2709 }
2710
2711 memcpy(&obj->state.hardwareCamera.projection,
2712 &event->xclient.data.l[0], sizeof(int));
2713 float temp;
2714 memcpy(&temp, &event->xclient.data.l[1], sizeof(float));
2715 obj->state.hardwareCamera.zoomFactor = temp;
2716 memcpy(&temp, &event->xclient.data.l[2], sizeof(float));
2717 obj->state.hardwareCamera.viewAngle = temp;
2718 memcpy(&temp, &event->xclient.data.l[3], sizeof(float));
2719 obj->state.hardwareCamera.to[0] = temp;
2720 memcpy(&temp, &event->xclient.data.l[4], sizeof(float));
2721 obj->state.hardwareCamera.to[1] = temp;
2722
2723 }
2724 /*
2725 * Zoom2 message from GL:
2726 */
2727 else if (event->xclient.message_type == obj->atoms.zoom2)
2728 {
2729 /*
2730 * NOP if we have not recieved an image from the server.
2731 */
2732 if (obj->state.hardwareWindow == NUL(Window) ||
2733 !obj->directInteractionAllowed())
2734 {
2735 return;
2736 }
2737
2738 /*
2739 * Use the information from the Zoom1 message...
2740 */
2741 if(in)
2742 {
2743 if (obj->state.hardwareCamera.projection == 0)
2744 {
2745 double w;
2746 in->getWidth(w);
2747 w *= obj->state.hardwareCamera.zoomFactor;
2748 in->setWidth(w, FALSE);
2749 }
2750 else
2751 {
2752 in->setViewAngle(obj->state.hardwareCamera.viewAngle, FALSE);
2753 }
2754 }
2755 float temp;
2756 memcpy(&temp, &event->xclient.data.l[0], sizeof(float));
2757 obj->state.hardwareCamera.to[2] = temp;
2758 memcpy(&temp, &event->xclient.data.l[1], sizeof(float));
2759 obj->state.hardwareCamera.from[0] = temp;
2760 memcpy(&temp, &event->xclient.data.l[2], sizeof(float));
2761 obj->state.hardwareCamera.from[1] = temp;
2762 memcpy(&temp, &event->xclient.data.l[3], sizeof(float));
2763 obj->state.hardwareCamera.from[2] = temp;
2764
2765 if(in)
2766 {
2767 in->setTo(obj->state.hardwareCamera.to, FALSE);
2768 in->setFrom(obj->state.hardwareCamera.from, TRUE);
2769 }
2770
2771 if (!theDXApplication->getExecCtl()->inExecOnChange())
2772 theDXApplication->getExecCtl()->executeOnce();
2773 }
2774
2775 /*
2776 * Cursor Change message from GL:
2777 */
2778 else if (event->xclient.message_type == obj->atoms.cursor_change)
2779 {
2780 /*
2781 * NOP if we have not recieved an image from gl_render.
2782 */
2783 if (obj->state.hardwareWindow == NUL(Window))
2784 {
2785 return;
2786 }
2787
2788 int cursor_num = event->xclient.data.l[0];
2789 int reason = event->xclient.data.l[1];
2790 float temp;
2791 double x, y, z;
2792
2793 memcpy(&temp, &event->xclient.data.l[2], sizeof(float));
2794 x = (double)temp;
2795 memcpy(&temp, &event->xclient.data.l[3], sizeof(float));
2796 y = (double)temp;
2797 memcpy(&temp, &event->xclient.data.l[4], sizeof(float));
2798 z = (double)temp;
2799 obj->handleCursor(reason, cursor_num, x, y, z);
2800 }
2801
2802 /*
2803 * Image available from GL:
2804 */
2805 else if (event->xclient.message_type == obj->atoms.gl_window0)
2806 {
2807
2808 /*
2809 * Save the info.
2810 */
2811 obj->state.hardwareRender = TRUE;
2812 obj->state.hardwareRenderExists = TRUE;
2813 obj->state.hardwareWindow = event->xclient.data.l[0];
2814 float temp;
2815 memcpy(&temp, &event->xclient.data.l[1], sizeof(float));
2816 obj->state.hardwareCamera.to[0] = temp;
2817 memcpy(&temp, &event->xclient.data.l[2], sizeof(float));
2818 obj->state.hardwareCamera.to[1] = temp;
2819 memcpy(&temp, &event->xclient.data.l[3], sizeof(float));
2820 obj->state.hardwareCamera.to[2] = temp;
2821 memcpy(&temp, &event->xclient.data.l[4], sizeof(float));
2822 obj->state.hardwareCamera.up[0] = temp;
2823
2824 obj->configureImageDepthMenu();
2825 }
2826 else if (event->xclient.message_type == obj->atoms.gl_window1)
2827 {
2828 /*
2829 * Save the info.
2830 */
2831 float temp;
2832 memcpy(&temp, &event->xclient.data.l[0], sizeof(float));
2833 obj->state.hardwareCamera.up[1] = temp;
2834 memcpy(&temp, &event->xclient.data.l[1], sizeof(float));
2835 obj->state.hardwareCamera.up[2] = temp;
2836 memcpy(&temp, &event->xclient.data.l[2], sizeof(float));
2837 obj->state.hardwareCamera.from[0] = temp;
2838 memcpy(&temp, &event->xclient.data.l[3], sizeof(float));
2839 obj->state.hardwareCamera.from[1] = temp;
2840 memcpy(&temp, &event->xclient.data.l[4], sizeof(float));
2841 obj->state.hardwareCamera.from[2] = temp;
2842 }
2843 else if ( (event->xclient.message_type == obj->atoms.gl_window2) ||
2844 (event->xclient.message_type == obj->atoms.gl_window2_execute) )
2845 {
2846 obj->pushedSinceExec = FALSE;
2847
2848 float temp;
2849 memcpy(&temp, &event->xclient.data.l[0], sizeof(float));
2850 obj->state.hardwareCamera.width = temp;
2851 obj->state.hardwareCamera.windowWidth = event->xclient.data.l[1];
2852 memcpy(&temp, &event->xclient.data.l[2], sizeof(float));
2853 obj->state.hardwareCamera.aspect = temp;
2854 memcpy(&temp, &event->xclient.data.l[3], sizeof(float));
2855 obj->state.hardwareCamera.viewAngle = temp;
2856 obj->state.hardwareCamera.projection = event->xclient.data.l[4];
2857
2858 obj->state.hardwareCamera.windowHeight = (int)
2859 ( obj->state.hardwareCamera.aspect *
2860 obj->state.hardwareCamera.windowWidth );
2861
2862 //
2863 // Seems like we should keep these in sync.
2864 //
2865 obj->state.width = obj->state.hardwareCamera.windowWidth;
2866 obj->state.height = obj->state.hardwareCamera.windowHeight;
2867
2868 /*
2869 * If the projection is orthographic, calculate the equivalent view
2870 * angle. If it is perspective, calc the autocamera width.
2871 */
2872 double x = obj->state.hardwareCamera.from[0] -
2873 obj->state.hardwareCamera.to[0];
2874 double y = obj->state.hardwareCamera.from[1] -
2875 obj->state.hardwareCamera.to[1];
2876 double z = obj->state.hardwareCamera.from[2] -
2877 obj->state.hardwareCamera.to[2];
2878 double dist = sqrt(x * x + y * y + z * z);
2879
2880 if (obj->state.hardwareCamera.projection == 0)
2881 {
2882 double t = atan((obj->state.hardwareCamera.width/2)/dist);
2883 obj->state.hardwareCamera.viewAngle = (t * 360)/3.1415926;
2884 }
2885 else
2886 {
2887 obj->state.hardwareCamera.width =
2888 2*tan(3.1415926*obj->state.hardwareCamera.viewAngle/360.0)*dist;
2889 }
2890
2891
2892 if(in)
2893 {
2894 in->setWidth(obj->state.hardwareCamera.width, FALSE);
2895 in->setResolution(obj->state.hardwareCamera.windowWidth,
2896 obj->state.hardwareCamera.windowHeight, FALSE);
2897 in->setAspect(obj->state.hardwareCamera.aspect, FALSE);
2898 in->setTo(obj->state.hardwareCamera.to, FALSE);
2899 in->setUp(obj->state.hardwareCamera.up, FALSE);
2900 in->setFrom(obj->state.hardwareCamera.from, FALSE);
2901 in->setViewAngle(obj->state.hardwareCamera.viewAngle, FALSE);
2902 in->setProjection(obj->state.hardwareCamera.projection, FALSE);
2903 }
2904 if (obj->viewControlDialog)
2905 {
2906 obj->viewControlDialog->resetProjection();
2907 obj->viewControlDialog->setWhichCameraVector();
2908 }
2909
2910 if(in)
2911 in->enableVector(TRUE, FALSE);
2912
2913 if (event->xclient.message_type == obj->atoms.gl_window2_execute)
2914 {
2915 if(in)
2916 in->sendValues(FALSE);
2917 boolean execOnChange =
2918 theDXApplication->getExecCtl()->inExecOnChange();
2919 if (!execOnChange)
2920 theDXApplication->getExecCtl()->executeOnce();
2921 }
2922 else if (in)
2923 in->sendValuesQuietly();
2924
2925 //
2926 // Set the View Control Dialog Sensitivity
2927 //
2928 if (obj->viewControlDialog && obj->directInteractionAllowed())
2929 {
2930 if(in)
2931 obj->viewControlDialog->setSensitivity(in->useVector());
2932 }
2933 if(!obj->isManaged()) obj->DXWindow::manage();
2934
2935 obj->newCanvasImage();
2936 obj->allowDirectInteraction(in == NULL ? FALSE : TRUE);
2937 }
2938 else if (event->xclient.message_type == obj->atoms.execute_on_change)
2939 {
2940 theDXApplication->executeOnChangeCmd->execute();
2941 }
2942 else if (event->xclient.message_type == obj->atoms.pick_point)
2943 {
2944 /*
2945 * NOP if we have not recieved an image from the server.
2946 */
2947 if (obj->state.hardwareWindow == NUL(Window) ||
2948 !obj->directInteractionAllowed())
2949 {
2950 return;
2951 }
2952
2953 float x,y;
2954
2955 memcpy(&x, &event->xclient.data.l[0], sizeof(float));
2956 memcpy(&y, &event->xclient.data.l[1], sizeof(float));
2957
2958 obj->pickImage((double)x, (double)y);
2959 }
2960
2961 /*
2962 * Image information message from the (Workstation) DX server:
2963 */
2964 else
2965 {
2966 obj->state.hardwareRender = FALSE;
2967 /*
2968 * Resize the image.
2969 */
2970 switch (event->xclient.format)
2971 {
2972 case 16:
2973 width = event->xclient.data.s[0];
2974 height = event->xclient.data.s[1];
2975 //depth = event->xclient.data.s[2];
2976 break;
2977
2978 case 32:
2979 width = event->xclient.data.l[0];
2980 height = event->xclient.data.l[1];
2981 //depth = event->xclient.data.l[2];
2982 break;
2983
2984 default:
2985 ErrorMessage("Invalid format of UI/Server client message");
2986 return;
2987 }
2988
2989 //
2990 // resize_from_server = True ==> do not cause a re-execution
2991 // in the resize callback.
2992 //
2993
2994 obj->state.resizeFromServer = TRUE;
2995 XtVaSetValues(obj->getCanvas(),
2996 XmNwidth, width,
2997 XmNheight, height, NULL);
2998 obj->state.resizeFromServer = FALSE;
2999 obj->state.width = width;
3000 obj->state.height = height;
3001
3002 /*
3003 * Get the pixmap id from the window property list each time
3004 * in case the pixmap has been changed by the SVS server.
3005 */
3006 Atom actual_type;
3007 int actual_format;
3008 unsigned long n_items;
3009 unsigned long bytes_after;
3010 Pixmap *pixmap;
3011 XGetWindowProperty
3012 (XtDisplay(imageWindow),
3013 event->xclient.window,
3014 obj->atoms.dx_pixmap_id,
3015 0,
3016 1,
3017 FALSE,
3018 XA_PIXMAP,
3019 &actual_type,
3020 &actual_format,
3021 &n_items,
3022 &bytes_after,
3023 (unsigned char**)&pixmap);
3024
3025 /*
3026 * Draw the image if we have a pixmap to use...
3027 */
3028 if (actual_type != None)
3029 {
3030 obj->state.pixmap = *pixmap;
3031 if(!obj->state.gc)
3032 {
3033 //
3034 // Create Graphics Context
3035 //
3036 obj->state.gc = XCreateGC
3037 (XtDisplay(obj->getCanvas()),
3038 XtWindow(obj->getCanvas()),
3039 NUL(long),
3040 NUL(XGCValues*));
3041 Pixel bg;
3042 XtVaGetValues(obj->getCanvas(), XmNbackground, &bg, NULL);
3043 XSetForeground(XtDisplay(obj->getCanvas()), obj->state.gc, bg);
3044 }
3045
3046 XCopyArea
3047 (XtDisplay(imageWindow),
3048 obj->state.pixmap,
3049 XtWindow(obj->getCanvas()),
3050 obj->state.gc,
3051 0, 0,
3052 obj->state.width,
3053 obj->state.height,
3054 0, 0);
3055
3056 Dimension wwidth, wheight;
3057 XtVaGetValues(obj->getCanvas(),
3058 XmNwidth, &wwidth,
3059 XmNheight, &wheight,
3060 NULL);
3061 if (wwidth > obj->state.width)
3062 {
3063 XFillRectangle(XtDisplay(obj->getCanvas()),
3064 XtWindow(obj->getCanvas()),
3065 obj->state.gc,
3066 obj->state.width, 0,
3067 wwidth - obj->state.width, wheight);
3068 }
3069 if (wheight > obj->state.height)
3070 {
3071 XFillRectangle(XtDisplay(obj->getCanvas()),
3072 XtWindow(obj->getCanvas()),
3073 obj->state.gc,
3074 0, obj->state.height,
3075 obj->state.width, wheight - obj->state.height);
3076 }
3077
3078 XFlush(XtDisplay(imageWindow));
3079 XtVaSetValues(obj->getCanvas(),
3080 XmNpicturePixmap, obj->state.pixmap,
3081 XmNoverlayExposure, True,
3082 XmNnewImage, True,
3083 NULL);
3084 XFree((char*)pixmap);
3085 }
3086 else
3087 {
3088 XClearWindow(XtDisplay(imageWindow), XtWindow(imageWindow));
3089 XDeleteProperty
3090 (XtDisplay(imageWindow),
3091 event->xclient.window,
3092 obj->atoms.dx_pixmap_id);
3093 }
3094
3095 XDeleteProperty
3096 (XtDisplay(imageWindow),
3097 event->xclient.window,
3098 obj->atoms.dx_flag);
3099
3100 // put the system back into rotate mode if that's the mode it was
3101 // in before.
3102 boolean sw;
3103 obj->getSoftware(sw);
3104 if (obj->switchingSoftware && sw)
3105 {
3106 XmPictureAlign((XmPictureWidget)obj->getCanvas());
3107 if (obj->viewControlDialog)
3108 obj->viewControlDialog->resetLookDirection();
3109
3110 DirectInteractionMode m = obj->getInteractionMode();
3111 obj->setInteractionMode(NONE);
3112 obj->setInteractionMode(m);
3113 obj->undoCmd->deactivate();
3114 obj->redoCmd->deactivate();
3115 obj->switchingSoftware = FALSE;
3116 }
3117
3118 //
3119 // Set the View Control Dialog Sensitivity
3120 //
3121 if (obj->viewControlDialog && obj->directInteractionAllowed())
3122 {
3123 if(in)
3124 obj->viewControlDialog->setSensitivity(in->useVector());
3125 }
3126
3127 if(!obj->isManaged()) obj->DXWindow::manage();
3128 }
3129 }
3130
3131 //
3132 // Return TRUE/FALSE if the window is/isn't associated with a node.
3133 //
isAssociatedWithNode()3134 boolean ImageWindow::isAssociatedWithNode()
3135 {
3136 return this->node != NULL;
3137 }
3138 //
3139 // This routine is used to associate/disassociate a node with an ImageWindow.
3140 // If n is NULL, it disassociates the ImageWindow from the current Node.
3141 // Otherwise, if it's already associated with a node, it returns false.
3142 // Otherwise, it associates itself, setting up commands, ....
3143 //
associateNode(Node * n)3144 boolean ImageWindow::associateNode(Node *n)
3145 {
3146 boolean ret;
3147
3148 if (n == NULL)
3149 {
3150 if (this->node == NULL) // Stop recursion with DisplayNode::associateImage()
3151 return TRUE;
3152
3153 DisplayNode *n = (DisplayNode*)this->node;
3154 this->node = NULL;
3155 n->associateImage(NULL);
3156 this->allowDirectInteraction(FALSE);
3157 this->setInteractionMode(NONE);
3158
3159 //
3160 // Deactivate commands
3161 //
3162 this->renderingOptionsCmd->deactivate();
3163 this->autoAxesCmd->deactivate();
3164 this->throttleCmd->deactivate();
3165 this->viewControlCmd->deactivate();
3166 this->backgroundColorCmd->deactivate();
3167 this->undoCmd->deactivate();
3168 this->redoCmd->deactivate();
3169 this->resetCmd->deactivate();
3170 if (this->changeImageNameCmd)
3171 this->changeImageNameCmd->deactivate();
3172 this->backgroundColorCmd->deactivate();
3173 this->displayRotationGlobeCmd->deactivate();
3174 // Image depth menu is done below with configureImageDepthMenu()
3175 if (this->saveImageCmd) this->saveImageCmd->deactivate();
3176 if (this->printImageCmd) this->printImageCmd->deactivate();
3177 if (this->setPanelAccessCmd)
3178 this->setPanelAccessCmd->deactivate();
3179
3180 //
3181 // Clean up the dialogs
3182 //
3183 if (this->viewControlDialog)
3184 {
3185 this->viewControlDialog->unmanage();
3186 delete this->viewControlDialog;
3187 this->viewControlDialog = NULL;
3188 }
3189 if (this->renderingOptionsDialog)
3190 {
3191 this->renderingOptionsDialog->unmanage();
3192 delete this->renderingOptionsDialog;
3193 this->renderingOptionsDialog = NULL;
3194 }
3195 if (this->backgroundColorDialog)
3196 {
3197 this->backgroundColorDialog->unmanage();
3198 delete this->backgroundColorDialog;
3199 this->backgroundColorDialog = NULL;
3200 }
3201 if (this->throttleDialog)
3202 {
3203 this->throttleDialog->unmanage();
3204 delete this->throttleDialog;
3205 this->throttleDialog = NULL;
3206 }
3207 if (this->autoAxesDialog)
3208 {
3209 this->autoAxesDialog->unmanage();
3210 delete this->autoAxesDialog;
3211 this->autoAxesDialog = NULL;
3212 }
3213 if (this->changeImageNameDialog)
3214 {
3215 this->changeImageNameDialog->unmanage();
3216 delete this->changeImageNameDialog;
3217 this->changeImageNameDialog = NULL;
3218 }
3219 if (this->saveImageDialog)
3220 {
3221 this->saveImageDialog->unmanage();
3222 delete this->saveImageDialog;
3223 this->saveImageDialog = NULL;
3224 }
3225 if (this->printImageDialog)
3226 {
3227 this->printImageDialog->unmanage();
3228 delete this->printImageDialog;
3229 this->printImageDialog = NULL;
3230 }
3231
3232
3233 //
3234 // Remove the commands from the auto list.
3235 //
3236 /*
3237 if (this->printImageCmd) {
3238 theDXApplication->executingCmd->removeAutoCmd(this->printImageCmd);
3239 theDXApplication->notExecutingCmd->removeAutoCmd(
3240 this->printImageCmd);
3241 }
3242 if (this->saveImageCmd) {
3243 theDXApplication->executingCmd->removeAutoCmd(this->saveImageCmd);
3244 theDXApplication->notExecutingCmd->removeAutoCmd(
3245 this->saveImageCmd);
3246 }
3247 */
3248
3249 this->softwareCmd->deactivate();
3250 this->hardwareCmd->deactivate();
3251 this->upNoneCmd->deactivate();
3252 this->upWireframeCmd->deactivate();
3253 this->upDotsCmd->deactivate();
3254 this->upBoxCmd->deactivate();
3255 this->downNoneCmd->deactivate();
3256 this->downWireframeCmd->deactivate();
3257 this->downDotsCmd->deactivate();
3258 this->downBoxCmd->deactivate();
3259
3260 this->modeCursorsCmd->deactivate();
3261 this->modePickCmd->deactivate();
3262
3263 if(this->state.hardwareRenderExists)
3264 {
3265 this->sendClientMessage(this->atoms.gl_destroy_window);
3266 this->wait4GLAcknowledge();
3267 }
3268
3269 ret = TRUE;
3270 }
3271 else
3272 {
3273 if (this->node == NULL)
3274 {
3275 ASSERT(n->isA(ClassDisplayNode));
3276 this->node = n;
3277 int depth = ((DisplayNode*)n)->getDepth();
3278 this->adjustDepth(depth);
3279 this->changeDepth(depth);
3280
3281
3282 if (this->setPanelAccessCmd && this->network->getPanelCount())
3283 this->setPanelAccessCmd->activate();
3284
3285 if (n->isA(ClassImageNode))
3286 {
3287 if (this->changeImageNameCmd &&
3288 ((ImageNode*)n)->isImageNameInputSet())
3289 this->changeImageNameCmd->activate();
3290
3291 this->viewControlCmd->activate();
3292 this->autoAxesCmd->activate();
3293 if (this->saveImageCmd)
3294 this->saveImageCmd->activate();
3295 if (this->printImageCmd)
3296 this->printImageCmd->activate();
3297 this->throttleCmd->activate();
3298 this->backgroundColorCmd->activate();
3299 this->resetCmd->activate();
3300 this->displayRotationGlobeCmd->activate();
3301 this->renderingOptionsCmd->activate();
3302 this->softwareCmd->activate();
3303 this->hardwareCmd->activate();
3304 this->upNoneCmd->activate();
3305 this->upDotsCmd->activate();
3306 this->upBoxCmd->activate();
3307 this->downNoneCmd->activate();
3308 this->downDotsCmd->activate();
3309 this->downBoxCmd->activate();
3310
3311 if (this->viewControlDialog)
3312 {
3313 this->viewControlDialog->setSensitivity(
3314 ((ImageNode*)n)->useVector());
3315 }
3316
3317 //
3318 // Set the activation of commands that depend on execution.
3319 //
3320 if (this->saveImageDialog)
3321 this->saveImageDialog->associateNode((ImageNode*)n);
3322 if (this->printImageDialog)
3323 this->printImageDialog->associateNode((ImageNode*)n);
3324
3325 if (!((DisplayNode*)n)->useSoftwareRendering())
3326 {
3327 this->upWireframeCmd->activate();
3328 this->downWireframeCmd->activate();
3329 }
3330 else
3331 {
3332 this->upWireframeCmd->deactivate();
3333 this->downWireframeCmd->deactivate();
3334 }
3335
3336
3337 List *l = this->network->makeClassifiedNodeList(ClassProbeNode,
3338 FALSE);
3339 if (l) {
3340 delete l;
3341 this->modeCursorsCmd->activate();
3342 } else
3343 this->modeCursorsCmd->deactivate();
3344
3345 l = this->network->makeClassifiedNodeList(ClassPickNode);
3346 if (l) {
3347 delete l;
3348 this->modePickCmd->activate();
3349 } else
3350 this->modePickCmd->deactivate();
3351 }
3352
3353 ret = TRUE;
3354 }
3355 else
3356 {
3357 ret = FALSE;
3358 }
3359 }
3360
3361 this->configureImageDepthMenu();
3362 this->resetWindowTitle();
3363 this->configureModeMenu();
3364
3365 if (this->execute_after_resize_to) XtRemoveTimeOut (this->execute_after_resize_to);
3366 this->execute_after_resize_to = 0;
3367
3368 return ret;
3369 }
3370
resetWindowTitle()3371 void ImageWindow::resetWindowTitle()
3372 {
3373 DisplayNode *dmn = (DisplayNode*)this->node;
3374 const char *title = NULL;
3375 char *t = NULL;
3376
3377 if (dmn)
3378 title = dmn->getTitle();
3379
3380 if (!title) {
3381 const char *file = this->network->getFileName();
3382 const char *node_name ;
3383 if (dmn)
3384 node_name = dmn->getNameString();
3385 else
3386 node_name = "Image";
3387 if (!file) {
3388 title = node_name;
3389 } else {
3390 t = new char[STRLEN(file) + STRLEN(node_name) + 3];
3391 sprintf(t,"%s: %s", node_name,file);
3392 title = t;
3393 }
3394 }
3395 ASSERT(title);
3396 this->setWindowTitle(title);
3397 if (t) delete t;
3398 }
3399
allowDirectInteraction(boolean allow)3400 void ImageWindow::allowDirectInteraction(boolean allow)
3401 {
3402 if (this->directInteraction == allow)
3403 return;
3404
3405 ASSERT(!allow || (this->node && this->node->isA(ClassImageNode)));
3406
3407 this->directInteraction = allow;
3408 if (allow)
3409 {
3410 this->setInteractionMode(NONE);
3411
3412 ImageNode *in = (ImageNode*)this->node;
3413
3414 boolean sw;
3415 this->getSoftware(sw);
3416 if (sw)
3417 {
3418 if (XmPictureUndoable((XmPictureWidget)this->getCanvas()))
3419 this->getUndoCmd()->activate();
3420 else
3421 this->getUndoCmd()->deactivate();
3422 if (XmPictureRedoable((XmPictureWidget)this->getCanvas()))
3423 this->getRedoCmd()->activate();
3424 else
3425 this->getRedoCmd()->deactivate();
3426 }
3427
3428 this->resetCmd->activate();
3429 this->displayRotationGlobeCmd->activate();
3430 if (this->viewControlDialog)
3431 {
3432 this->viewControlDialog->setSensitivity(in->useVector());
3433 this->viewControlDialog->sensitizePickOptionMenu(TRUE);
3434 this->viewControlDialog->sensitizeProbeOptionMenu(TRUE);
3435 }
3436
3437
3438 if (this->network->containsClassOfNode(ClassProbeNode) > 0)
3439 this->modeCursorsCmd->activate();
3440 else
3441 this->modeCursorsCmd->deactivate();
3442 if (this->network->containsClassOfNode(ClassPickNode))
3443 this->modePickCmd->activate();
3444 else
3445 this->modePickCmd->deactivate();
3446
3447 this->modeNoneCmd->activate();
3448 this->modeCameraCmd->activate();
3449 this->modeNavigateCmd->activate();
3450 this->modePanZoomCmd->activate();
3451 this->modeRoamCmd->activate();
3452 this->modeRotateCmd->activate();
3453 this->modeZoomCmd->activate();
3454
3455 }
3456 else
3457 {
3458 this->undoCmd->deactivate();
3459 this->redoCmd->deactivate();
3460 this->resetCmd->deactivate();
3461 this->displayRotationGlobeCmd->deactivate();
3462
3463 this->modeCursorsCmd->deactivate();
3464 this->modePickCmd->deactivate();
3465
3466 this->modeNoneCmd->deactivate();
3467 this->modeCameraCmd->deactivate();
3468 this->modeNavigateCmd->deactivate();
3469 this->modePanZoomCmd->deactivate();
3470 this->modeRoamCmd->deactivate();
3471 this->modeRotateCmd->deactivate();
3472 this->modeZoomCmd->deactivate();
3473 if(this->viewControlDialog)
3474 {
3475 this->viewControlDialog->setSensitivity(FALSE);
3476 this->viewControlDialog->sensitizePickOptionMenu(FALSE);
3477 this->viewControlDialog->sensitizeProbeOptionMenu(FALSE);
3478 }
3479 }
3480 this->configureModeMenu();
3481 }
3482
postRenderingOptionsDialog()3483 boolean ImageWindow::postRenderingOptionsDialog()
3484 {
3485 if (this->renderingOptionsDialog == NULL)
3486 this->renderingOptionsDialog = new RenderingOptionsDialog(
3487 this->getRootWidget(),
3488 this);
3489 this->renderingOptionsDialog->post();
3490 // Force Image's Translations onto renderingOptionsDialog here.
3491 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3492 this->saveOption->getRootWidget(), "ArmAndActivate");
3493 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3494 this->saveImageOption->getRootWidget(), "ArmAndActivate");
3495 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3496 this->printImageOption->getRootWidget(), "ArmAndActivate");
3497 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3498 this->closeOption->getRootWidget(), "ArmAndActivate");
3499 if(this->openAllControlPanelsOption)
3500 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3501 this->openAllControlPanelsOption->getRootWidget(), "ArmAndActivate");
3502 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3503 this->openAllColormapEditorsOption->getRootWidget(), "ArmAndActivate");
3504 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3505 this->messageWindowOption->getRootWidget(), "ArmAndActivate");
3506 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3507 this->undoOption->getRootWidget(), "ArmAndActivate");
3508 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3509 this->redoOption->getRootWidget(), "ArmAndActivate");
3510 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3511 this->resetOption->getRootWidget(), "ArmAndActivate");
3512 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3513 this->executeOnceOption->getRootWidget(), "ArmAndActivate");
3514 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3515 this->executeOnChangeOption->getRootWidget(), "ArmAndActivate");
3516 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3517 this->endExecutionOption->getRootWidget(), "ArmAndActivate");
3518
3519 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3520 this->modeCameraOption->getRootWidget(), "ArmAndActivate");
3521 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3522 this->modeCursorsOption->getRootWidget(), "ArmAndActivate");
3523 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3524 this->modePickOption->getRootWidget(), "ArmAndActivate");
3525 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3526 this->modeNavigateOption->getRootWidget(), "ArmAndActivate");
3527 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3528 this->modePanZoomOption->getRootWidget(), "ArmAndActivate");
3529 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3530 this->modeRoamOption->getRootWidget(), "ArmAndActivate");
3531 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3532 this->modeRotateOption->getRootWidget(), "ArmAndActivate");
3533 TransferAccelerator(this->renderingOptionsDialog->getRootWidget(),
3534 this->modeZoomOption->getRootWidget(), "ArmAndActivate");
3535
3536 return TRUE;
3537 }
postAutoAxesDialog()3538 boolean ImageWindow::postAutoAxesDialog()
3539 {
3540 if (this->autoAxesDialog == NULL)
3541 this->autoAxesDialog = new AutoAxesDialog(this);
3542
3543 this->autoAxesDialog->post();
3544 // Force Image's Translations onto autoAxesDialog here.
3545 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3546 this->saveOption->getRootWidget(), "ArmAndActivate");
3547 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3548 this->saveImageOption->getRootWidget(), "ArmAndActivate");
3549 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3550 this->printImageOption->getRootWidget(), "ArmAndActivate");
3551 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3552 this->closeOption->getRootWidget(), "ArmAndActivate");
3553 if(this->openAllControlPanelsOption)
3554 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3555 this->openAllControlPanelsOption->getRootWidget(), "ArmAndActivate");
3556 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3557 this->openAllColormapEditorsOption->getRootWidget(), "ArmAndActivate");
3558 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3559 this->messageWindowOption->getRootWidget(), "ArmAndActivate");
3560 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3561 this->undoOption->getRootWidget(), "ArmAndActivate");
3562 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3563 this->redoOption->getRootWidget(), "ArmAndActivate");
3564 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3565 this->resetOption->getRootWidget(), "ArmAndActivate");
3566 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3567 this->executeOnceOption->getRootWidget(), "ArmAndActivate");
3568 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3569 this->executeOnChangeOption->getRootWidget(), "ArmAndActivate");
3570 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3571 this->endExecutionOption->getRootWidget(), "ArmAndActivate");
3572
3573 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3574 this->modeCameraOption->getRootWidget(), "ArmAndActivate");
3575 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3576 this->modeCursorsOption->getRootWidget(), "ArmAndActivate");
3577 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3578 this->modePickOption->getRootWidget(), "ArmAndActivate");
3579 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3580 this->modeNavigateOption->getRootWidget(), "ArmAndActivate");
3581 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3582 this->modePanZoomOption->getRootWidget(), "ArmAndActivate");
3583 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3584 this->modeRoamOption->getRootWidget(), "ArmAndActivate");
3585 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3586 this->modeRotateOption->getRootWidget(), "ArmAndActivate");
3587 TransferAccelerator(this->autoAxesDialog->getRootWidget(),
3588 this->modeZoomOption->getRootWidget(), "ArmAndActivate");
3589
3590 return TRUE;
3591 }
3592
postVPE()3593 boolean ImageWindow::postVPE()
3594 {
3595 if(NOT this->network)
3596 return FALSE;
3597
3598 EditorWindow* editor = this->network->getEditor();
3599
3600 if (NOT editor)
3601 editor = theDXApplication->newNetworkEditor(this->network);
3602
3603 if (editor) {
3604 editor->manage();
3605 XMapRaised(XtDisplay(editor->getRootWidget()),
3606 XtWindow(editor->getRootWidget()));
3607 }
3608
3609 return TRUE;
3610 }
3611
postThrottleDialog()3612 boolean ImageWindow::postThrottleDialog()
3613 {
3614 if (this->throttleDialog == NULL)
3615 this->throttleDialog = new ThrottleDialog(
3616 "throttleDialog",
3617 this);
3618
3619 this->throttleDialog->post();
3620 // Force Image's Translations onto throttleDialog here.
3621 TransferAccelerator(this->throttleDialog->getRootWidget(),
3622 this->saveOption->getRootWidget(), "ArmAndActivate");
3623 TransferAccelerator(this->throttleDialog->getRootWidget(),
3624 this->saveImageOption->getRootWidget(), "ArmAndActivate");
3625 TransferAccelerator(this->throttleDialog->getRootWidget(),
3626 this->printImageOption->getRootWidget(), "ArmAndActivate");
3627 TransferAccelerator(this->throttleDialog->getRootWidget(),
3628 this->closeOption->getRootWidget(), "ArmAndActivate");
3629 if(this->openAllControlPanelsOption)
3630 TransferAccelerator(this->throttleDialog->getRootWidget(),
3631 this->openAllControlPanelsOption->getRootWidget(), "ArmAndActivate");
3632 TransferAccelerator(this->throttleDialog->getRootWidget(),
3633 this->openAllColormapEditorsOption->getRootWidget(), "ArmAndActivate");
3634 TransferAccelerator(this->throttleDialog->getRootWidget(),
3635 this->messageWindowOption->getRootWidget(), "ArmAndActivate");
3636 TransferAccelerator(this->throttleDialog->getRootWidget(),
3637 this->undoOption->getRootWidget(), "ArmAndActivate");
3638 TransferAccelerator(this->throttleDialog->getRootWidget(),
3639 this->redoOption->getRootWidget(), "ArmAndActivate");
3640 TransferAccelerator(this->throttleDialog->getRootWidget(),
3641 this->resetOption->getRootWidget(), "ArmAndActivate");
3642 TransferAccelerator(this->throttleDialog->getRootWidget(),
3643 this->executeOnceOption->getRootWidget(), "ArmAndActivate");
3644 TransferAccelerator(this->throttleDialog->getRootWidget(),
3645 this->executeOnChangeOption->getRootWidget(), "ArmAndActivate");
3646 TransferAccelerator(this->throttleDialog->getRootWidget(),
3647 this->endExecutionOption->getRootWidget(), "ArmAndActivate");
3648
3649 TransferAccelerator(this->throttleDialog->getRootWidget(),
3650 this->modeCameraOption->getRootWidget(), "ArmAndActivate");
3651 TransferAccelerator(this->throttleDialog->getRootWidget(),
3652 this->modeCursorsOption->getRootWidget(), "ArmAndActivate");
3653 TransferAccelerator(this->throttleDialog->getRootWidget(),
3654 this->modePickOption->getRootWidget(), "ArmAndActivate");
3655 TransferAccelerator(this->throttleDialog->getRootWidget(),
3656 this->modeNavigateOption->getRootWidget(), "ArmAndActivate");
3657 TransferAccelerator(this->throttleDialog->getRootWidget(),
3658 this->modePanZoomOption->getRootWidget(), "ArmAndActivate");
3659 TransferAccelerator(this->throttleDialog->getRootWidget(),
3660 this->modeRoamOption->getRootWidget(), "ArmAndActivate");
3661 TransferAccelerator(this->throttleDialog->getRootWidget(),
3662 this->modeRotateOption->getRootWidget(), "ArmAndActivate");
3663 TransferAccelerator(this->throttleDialog->getRootWidget(),
3664 this->modeZoomOption->getRootWidget(), "ArmAndActivate");
3665
3666
3667 return TRUE;
3668 }
postViewControlDialog()3669 boolean ImageWindow::postViewControlDialog()
3670 {
3671 boolean newDialog = FALSE;
3672 if (this->viewControlDialog == NULL)
3673 {
3674 this->viewControlDialog = new ViewControlDialog(this->getRootWidget(),
3675 this);
3676 newDialog = TRUE;
3677 }
3678
3679 if (this->viewControlDialog->isManaged())
3680 return TRUE;
3681
3682 this->viewControlDialog->post();
3683 // Force Image's Translations onto ViewControlDialog here.
3684 TransferAccelerator(this->viewControlDialog->getRootWidget(),
3685 this->saveOption->getRootWidget(), "ArmAndActivate");
3686 TransferAccelerator(this->viewControlDialog->getRootWidget(),
3687 this->saveImageOption->getRootWidget(), "ArmAndActivate");
3688 TransferAccelerator(this->viewControlDialog->getRootWidget(),
3689 this->printImageOption->getRootWidget(), "ArmAndActivate");
3690 TransferAccelerator(this->viewControlDialog->getRootWidget(),
3691 this->closeOption->getRootWidget(), "ArmAndActivate");
3692 if(this->openAllControlPanelsOption)
3693 TransferAccelerator(this->viewControlDialog->getRootWidget(),
3694 this->openAllControlPanelsOption->getRootWidget(), "ArmAndActivate");
3695 TransferAccelerator(this->viewControlDialog->getRootWidget(),
3696 this->openAllColormapEditorsOption->getRootWidget(), "ArmAndActivate");
3697 TransferAccelerator(this->viewControlDialog->getRootWidget(),
3698 this->messageWindowOption->getRootWidget(), "ArmAndActivate");
3699 TransferAccelerator(this->viewControlDialog->getRootWidget(),
3700 this->undoOption->getRootWidget(), "ArmAndActivate");
3701 TransferAccelerator(this->viewControlDialog->getRootWidget(),
3702 this->redoOption->getRootWidget(), "ArmAndActivate");
3703 TransferAccelerator(this->viewControlDialog->getRootWidget(),
3704 this->resetOption->getRootWidget(), "ArmAndActivate");
3705 TransferAccelerator(this->viewControlDialog->getRootWidget(),
3706 this->executeOnceOption->getRootWidget(), "ArmAndActivate");
3707 TransferAccelerator(this->viewControlDialog->getRootWidget(),
3708 this->executeOnChangeOption->getRootWidget(), "ArmAndActivate");
3709 TransferAccelerator(this->viewControlDialog->getRootWidget(),
3710 this->endExecutionOption->getRootWidget(), "ArmAndActivate");
3711
3712 if (this->directInteractionAllowed())
3713 {
3714 ImageNode *in = (ImageNode*)this->node;
3715 this->viewControlDialog->setSensitivity(
3716 this->state.pixmap != 0 && in->useVector());
3717 if (newDialog)
3718 {
3719 DirectInteractionMode m = this->getInteractionMode();
3720 this->setInteractionMode(NONE);
3721 this->setInteractionMode(m);
3722 }
3723 }
3724 else
3725 this->viewControlDialog->setSensitivity(FALSE);
3726
3727 return TRUE;
3728 }
postChangeImageNameDialog()3729 boolean ImageWindow::postChangeImageNameDialog()
3730 {
3731 if (NOT this->changeImageNameDialog)
3732 this->changeImageNameDialog = new SetImageNameDialog(this);
3733 this->changeImageNameDialog->post();
3734
3735 return TRUE;
3736 }
3737
enablePerspective(boolean enable)3738 boolean ImageWindow::enablePerspective(boolean enable)
3739 {
3740 if (!this->node->isA(ClassImageNode))
3741 return FALSE;
3742
3743 ImageNode *in = (ImageNode*)this->node;
3744
3745 boolean oldProj;
3746 in->getProjection(oldProj);
3747 if (oldProj == enable)
3748 return TRUE;
3749
3750
3751 /*
3752 * Save this camera so it can be undone later.
3753 */
3754 if (!this->pushedSinceExec)
3755 {
3756 if (this->state.hardwareRender)
3757 this->sendClientMessage(this->atoms.push_camera);
3758 else
3759 XmPicturePushUndoCamera((XmPictureWidget)this->getCanvas());
3760 this->pushedSinceExec = TRUE;
3761 }
3762
3763 /*
3764 * If we are going to an orthographic projection, calculate an autocamera
3765 * width from the perspective camera. If we are going to a perspective
3766 * projection, calculate a view angle from the orthographic camera.
3767 */
3768 if (this->state.hardwareRender)
3769 {
3770 double dx = this->state.hardwareCamera.to[0] -
3771 this->state.hardwareCamera.from[0];
3772 double dy = this->state.hardwareCamera.to[1] -
3773 this->state.hardwareCamera.from[1];
3774 double dz = this->state.hardwareCamera.to[2] -
3775 this->state.hardwareCamera.from[2];
3776 double length = sqrt( (dx * dx) + (dy * dy) + (dz * dz) );
3777
3778
3779 if (!enable)
3780 {
3781 double viewAngle = this->state.hardwareCamera.viewAngle;
3782
3783 double width = 2*length*tan((viewAngle/2.0)*3.14159/180.0);
3784 in->setWidth(width, FALSE);
3785 }
3786 else
3787 {
3788 double width = this->state.hardwareCamera.width;
3789 double viewAngle = 2*atan((width/2)/length)*180.0 / 3.14159;
3790 in->setViewAngle(viewAngle, FALSE);
3791 }
3792 }
3793 else
3794 {
3795 double to[3];
3796 in->getTo(to);
3797 double from[3];
3798 in->getFrom(from);
3799 double dx = to[0] - from[0];
3800 double dy = to[1] - from[1];
3801 double dz = to[2] - from[2];
3802 double length = sqrt( (dx * dx) + (dy * dy) + (dz * dz) );
3803 if (!enable)
3804 {
3805 double viewAngle;
3806 in->getViewAngle(viewAngle);
3807 double width = 2*length*tan((viewAngle/2.0)*3.14159/180.0);
3808 in->setWidth(width, FALSE);
3809 }
3810 else
3811 {
3812 double width;
3813 in->getWidth(width);
3814 double viewAngle = 2*atan((width/2)/length)*180.0 / 3.14159;
3815 in->setViewAngle(viewAngle, FALSE);
3816 }
3817 }
3818 in->setProjection(enable, TRUE);
3819
3820 if (this->viewControlDialog)
3821 {
3822 this->viewControlDialog->resetProjection();
3823 }
3824
3825 return TRUE;
3826 }
getPerspective()3827 boolean ImageWindow::getPerspective()
3828 {
3829 if (!this->node->isA(ClassImageNode))
3830 return FALSE;
3831
3832 ImageNode *in = (ImageNode*)this->node;
3833
3834 boolean persp;
3835 in->getProjection(persp);
3836
3837 return persp;
3838 }
getViewAngle(double & viewAngle)3839 void ImageWindow::getViewAngle(double &viewAngle)
3840 {
3841 if (!this->node->isA(ClassImageNode))
3842 return;
3843
3844 ImageNode *in = (ImageNode*)this->node;
3845
3846 in->getViewAngle(viewAngle);
3847 }
setViewAngle(double viewAngle)3848 void ImageWindow::setViewAngle(double viewAngle)
3849 {
3850 if (!this->node->isA(ClassImageNode))
3851 return;
3852
3853 if (!this->pushedSinceExec)
3854 {
3855 if (this->state.hardwareRender)
3856 this->sendClientMessage(this->atoms.push_camera);
3857 else
3858 XmPicturePushUndoCamera((XmPictureWidget)this->getCanvas());
3859 this->pushedSinceExec = TRUE;
3860 }
3861
3862 //
3863 // If the image window isn't in navigate mode, then move the from up
3864 // or back to keep the object the same size.
3865 // find the original width, determine the new distance to make the
3866 // view angle make stuff at the old distance look the same.
3867 //
3868 ImageNode *in = (ImageNode*)this->node;
3869 if (this->currentInteractionMode != NAVIGATE)
3870 {
3871 double oldViewAngle;
3872 in->getViewAngle(oldViewAngle);
3873
3874 oldViewAngle /= 360/(2*3.1415926);
3875 double newViewAngle = viewAngle/(360/(2*3.1415926));
3876
3877 double to[3];
3878 double from[3];
3879 in->getTo(to);
3880 in->getFrom(from);
3881 double x = from[0] - to[0];
3882 double y = from[1] - to[1];
3883 double z = from[2] - to[2];
3884 double dist = sqrt(x * x + y * y + z * z);
3885
3886 double oldWidth = dist * tan(oldViewAngle/2);
3887 double newDist = oldWidth/tan(newViewAngle/2);
3888
3889 x *= newDist/dist;
3890 y *= newDist/dist;
3891 z *= newDist/dist;
3892
3893 from[0] = to[0] + x;
3894 from[1] = to[1] + y;
3895 from[2] = to[2] + z;
3896
3897 in->setFrom(from, FALSE);
3898 }
3899
3900 in->setViewAngle(viewAngle, TRUE);
3901 }
setResolution(int x,int y)3902 void ImageWindow::setResolution(int x, int y)
3903 {
3904 if (!this->node->isA(ClassImageNode))
3905 return;
3906
3907 ImageNode *in = (ImageNode*)this->node;
3908
3909 /*
3910 * Otherwise, get the new width and height.
3911 */
3912 in->setResolution(x, y, FALSE);
3913 if (x == 0)
3914 return;
3915 double aspect = (y + 0.5) / x;
3916 in->setAspect(aspect, FALSE);
3917
3918 in->notifyWhereChange(TRUE);
3919 }
3920
getResolution(int & x,int & y)3921 void ImageWindow::getResolution(int &x, int &y)
3922 {
3923 if (!this->node->isA(ClassImageNode))
3924 return;
3925
3926 ImageNode *in = (ImageNode*)this->node;
3927
3928 in->getResolution(x, y);
3929 }
setThrottle(double w)3930 void ImageWindow::setThrottle(double w)
3931 {
3932 if (!this->node->isA(ClassImageNode))
3933 return;
3934 ((ImageNode*)this->node)->setThrottle(w);
3935 }
3936
getThrottle(double & w)3937 void ImageWindow::getThrottle(double &w)
3938 {
3939 if (!this->node->isA(ClassImageNode))
3940 return;
3941 ((ImageNode*)this->node)->getThrottle(w);
3942 }
3943
isAutoAxesCornersSet()3944 boolean ImageWindow::isAutoAxesCornersSet ()
3945 {
3946 if (!this->node->isA(ClassImageNode))
3947 return FALSE;
3948 return ((ImageNode*)this->node)->isAutoAxesCornersSet();
3949 }
3950
isAutoAxesLabelScaleSet()3951 boolean ImageWindow::isAutoAxesLabelScaleSet ()
3952 {
3953 if (!this->node->isA(ClassImageNode))
3954 return FALSE;
3955 return ((ImageNode*)this->node)->isAutoAxesLabelScaleSet();
3956 }
3957
isAutoAxesAnnotationSet()3958 boolean ImageWindow::isAutoAxesAnnotationSet ()
3959 {
3960 if (!this->node->isA(ClassImageNode))
3961 return FALSE;
3962 return ((ImageNode*)this->node)->isAutoAxesAnnotationSet();
3963 }
3964
isAutoAxesLabelsSet()3965 boolean ImageWindow::isAutoAxesLabelsSet ()
3966 {
3967 if (!this->node->isA(ClassImageNode))
3968 return FALSE;
3969 return ((ImageNode*)this->node)->isAutoAxesLabelsSet();
3970 }
3971
isAutoAxesColorsSet()3972 boolean ImageWindow::isAutoAxesColorsSet ()
3973 {
3974 if (!this->node->isA(ClassImageNode))
3975 return FALSE;
3976 return ((ImageNode*)this->node)->isAutoAxesColorsSet();
3977 }
3978
isAutoAxesFontSet()3979 boolean ImageWindow::isAutoAxesFontSet ()
3980 {
3981 if (!this->node->isA(ClassImageNode))
3982 return FALSE;
3983 return ((ImageNode*)this->node)->isAutoAxesFontSet();
3984 }
3985
isAutoAxesCursorSet()3986 boolean ImageWindow::isAutoAxesCursorSet ()
3987 {
3988 if (!this->node->isA(ClassImageNode))
3989 return FALSE;
3990 return ((ImageNode*)this->node)->isAutoAxesCursorSet();
3991 }
3992
isSetAutoAxesFrame()3993 boolean ImageWindow::isSetAutoAxesFrame ()
3994 {
3995 if (!this->node->isA(ClassImageNode))
3996 return FALSE;
3997 return ((ImageNode*)this->node)->isSetAutoAxesFrame();
3998 }
3999
isSetAutoAxesGrid()4000 boolean ImageWindow::isSetAutoAxesGrid ()
4001 {
4002 if (!this->node->isA(ClassImageNode))
4003 return FALSE;
4004 return ((ImageNode*)this->node)->isSetAutoAxesGrid();
4005 }
4006
isSetAutoAxesAdjust()4007 boolean ImageWindow::isSetAutoAxesAdjust ()
4008 {
4009 if (!this->node->isA(ClassImageNode))
4010 return FALSE;
4011 return ((ImageNode*)this->node)->isSetAutoAxesAdjust();
4012 }
4013
isAutoAxesTicksSet()4014 boolean ImageWindow::isAutoAxesTicksSet ()
4015 {
4016 if (!this->node->isA(ClassImageNode))
4017 return FALSE;
4018 return ((ImageNode*)this->node)->isAutoAxesTicksSet();
4019 }
4020
isAutoAxesXTickLocsSet()4021 boolean ImageWindow::isAutoAxesXTickLocsSet ()
4022 {
4023 if (!this->node->isA(ClassImageNode))
4024 return FALSE;
4025 return ((ImageNode*)this->node)->isAutoAxesXTickLocsSet();
4026 }
4027
isAutoAxesYTickLocsSet()4028 boolean ImageWindow::isAutoAxesYTickLocsSet ()
4029 {
4030 if (!this->node->isA(ClassImageNode))
4031 return FALSE;
4032 return ((ImageNode*)this->node)->isAutoAxesYTickLocsSet();
4033 }
4034
isAutoAxesZTickLocsSet()4035 boolean ImageWindow::isAutoAxesZTickLocsSet ()
4036 {
4037 if (!this->node->isA(ClassImageNode))
4038 return FALSE;
4039 return ((ImageNode*)this->node)->isAutoAxesZTickLocsSet();
4040 }
4041
isAutoAxesXTickLabelsSet()4042 boolean ImageWindow::isAutoAxesXTickLabelsSet ()
4043 {
4044 if (!this->node->isA(ClassImageNode))
4045 return FALSE;
4046 return ((ImageNode*)this->node)->isAutoAxesXTickLabelsSet();
4047 }
4048
isAutoAxesYTickLabelsSet()4049 boolean ImageWindow::isAutoAxesYTickLabelsSet ()
4050 {
4051 if (!this->node->isA(ClassImageNode))
4052 return FALSE;
4053 return ((ImageNode*)this->node)->isAutoAxesYTickLabelsSet();
4054 }
4055
isAutoAxesZTickLabelsSet()4056 boolean ImageWindow::isAutoAxesZTickLabelsSet ()
4057 {
4058 if (!this->node->isA(ClassImageNode))
4059 return FALSE;
4060 return ((ImageNode*)this->node)->isAutoAxesZTickLabelsSet();
4061 }
4062
unsetAutoAxesTicks(boolean send)4063 void ImageWindow::unsetAutoAxesTicks (boolean send)
4064 {
4065 if (!this->node->isA(ClassImageNode))
4066 return ;
4067 ((ImageNode*)this->node)->unsetAutoAxesTicks(send);
4068 }
4069
unsetAutoAxesXTickLocs(boolean send)4070 void ImageWindow::unsetAutoAxesXTickLocs (boolean send)
4071 {
4072 if (!this->node->isA(ClassImageNode))
4073 return ;
4074 ((ImageNode*)this->node)->unsetAutoAxesXTickLocs(send);
4075 }
4076
unsetAutoAxesYTickLocs(boolean send)4077 void ImageWindow::unsetAutoAxesYTickLocs (boolean send)
4078 {
4079 if (!this->node->isA(ClassImageNode))
4080 return ;
4081 ((ImageNode*)this->node)->unsetAutoAxesYTickLocs(send);
4082 }
4083
unsetAutoAxesZTickLocs(boolean send)4084 void ImageWindow::unsetAutoAxesZTickLocs (boolean send)
4085 {
4086 if (!this->node->isA(ClassImageNode))
4087 return ;
4088 ((ImageNode*)this->node)->unsetAutoAxesZTickLocs(send);
4089 }
4090
unsetAutoAxesXTickLabels(boolean send)4091 void ImageWindow::unsetAutoAxesXTickLabels (boolean send)
4092 {
4093 if (!this->node->isA(ClassImageNode))
4094 return ;
4095 ((ImageNode*)this->node)->unsetAutoAxesXTickLabels(send);
4096 }
4097
unsetAutoAxesYTickLabels(boolean send)4098 void ImageWindow::unsetAutoAxesYTickLabels (boolean send)
4099 {
4100 if (!this->node->isA(ClassImageNode))
4101 return ;
4102 ((ImageNode*)this->node)->unsetAutoAxesYTickLabels(send);
4103 }
4104
unsetAutoAxesZTickLabels(boolean send)4105 void ImageWindow::unsetAutoAxesZTickLabels (boolean send)
4106 {
4107 if (!this->node->isA(ClassImageNode))
4108 return ;
4109 ((ImageNode*)this->node)->unsetAutoAxesZTickLabels(send);
4110 }
4111
unsetAutoAxesLabels(boolean send)4112 void ImageWindow::unsetAutoAxesLabels (boolean send)
4113 {
4114 if (!this->node->isA(ClassImageNode))
4115 return ;
4116 ((ImageNode*)this->node)->unsetAutoAxesLabels(send);
4117 }
4118
unsetAutoAxesLabelScale(boolean send)4119 void ImageWindow::unsetAutoAxesLabelScale (boolean send)
4120 {
4121 if (!this->node->isA(ClassImageNode))
4122 return ;
4123 ((ImageNode*)this->node)->unsetAutoAxesLabelScale(send);
4124 }
4125
unsetAutoAxesFont(boolean send)4126 void ImageWindow::unsetAutoAxesFont (boolean send)
4127 {
4128 if (!this->node->isA(ClassImageNode))
4129 return ;
4130 ((ImageNode*)this->node)->unsetAutoAxesFont(send);
4131 }
4132
unsetAutoAxesEnable(boolean send)4133 void ImageWindow::unsetAutoAxesEnable (boolean send)
4134 {
4135 if (!this->node->isA(ClassImageNode))
4136 return ;
4137 ((ImageNode*)this->node)->unsetAutoAxesEnable(send);
4138 }
4139
unsetAutoAxesFrame(boolean send)4140 void ImageWindow::unsetAutoAxesFrame (boolean send)
4141 {
4142 if (!this->node->isA(ClassImageNode))
4143 return ;
4144 ((ImageNode*)this->node)->unsetAutoAxesFrame(send);
4145 }
4146
unsetAutoAxesGrid(boolean send)4147 void ImageWindow::unsetAutoAxesGrid (boolean send)
4148 {
4149 if (!this->node->isA(ClassImageNode))
4150 return ;
4151 ((ImageNode*)this->node)->unsetAutoAxesGrid(send);
4152 }
4153
unsetAutoAxesAdjust(boolean send)4154 void ImageWindow::unsetAutoAxesAdjust (boolean send)
4155 {
4156 if (!this->node->isA(ClassImageNode))
4157 return ;
4158 ((ImageNode*)this->node)->unsetAutoAxesAdjust(send);
4159 }
4160
getAutoAxesCursor(double * x,double * y,double * z)4161 void ImageWindow::getAutoAxesCursor (double *x, double *y, double *z)
4162 {
4163 if (!this->node->isA(ClassImageNode))
4164 return ;
4165 ((ImageNode*)this->node)->getAutoAxesCursor(x,y,z);
4166 }
4167
getAutoAxesCorners(double dval[])4168 void ImageWindow::getAutoAxesCorners (double dval[])
4169 {
4170 if (!this->node->isA(ClassImageNode))
4171 return ;
4172 ((ImageNode*)this->node)->getAutoAxesCorners(dval);
4173 }
4174
unsetAutoAxesCursor(boolean send)4175 void ImageWindow::unsetAutoAxesCursor (boolean send)
4176 {
4177 if (!this->node->isA(ClassImageNode))
4178 return ;
4179 ((ImageNode*)this->node)->unsetAutoAxesCursor(send);
4180 }
4181
unsetAutoAxesAnnotation(boolean send)4182 void ImageWindow::unsetAutoAxesAnnotation (boolean send)
4183 {
4184 if (!this->node->isA(ClassImageNode))
4185 return ;
4186 ((ImageNode*)this->node)->unsetAutoAxesAnnotation(send);
4187 }
4188
unsetAutoAxesColors(boolean send)4189 void ImageWindow::unsetAutoAxesColors (boolean send)
4190 {
4191 if (!this->node->isA(ClassImageNode))
4192 return ;
4193 ((ImageNode*)this->node)->unsetAutoAxesColors(send);
4194 }
4195
setAutoAxesCursor(double x,double y,double z,boolean send)4196 void ImageWindow::setAutoAxesCursor (double x, double y, double z, boolean send)
4197 {
4198 if (!this->node->isA(ClassImageNode))
4199 return ;
4200 ((ImageNode*)this->node)->setAutoAxesCursor(x, y, z, send);
4201 }
4202
unsetAutoAxesCorners(boolean send)4203 void ImageWindow::unsetAutoAxesCorners (boolean send)
4204 {
4205 if (!this->node->isA(ClassImageNode))
4206 return ;
4207 ((ImageNode*)this->node)->unsetAutoAxesCorners(send);
4208 }
4209
setAutoAxesCorners(double dval[],boolean send)4210 void ImageWindow::setAutoAxesCorners (double dval[], boolean send)
4211 {
4212 if (!this->node->isA(ClassImageNode))
4213 return ;
4214 ((ImageNode*)this->node)->setAutoAxesCorners(dval, send);
4215 }
4216
setAutoAxesTicks(int t1,int t2,int t3,boolean send)4217 void ImageWindow::setAutoAxesTicks (int t1, int t2, int t3, boolean send)
4218 {
4219 if (!this->node->isA(ClassImageNode))
4220 return ;
4221 ((ImageNode*)this->node)->setAutoAxesTicks (t1, t2, t3, send);
4222 }
4223
setAutoAxesTicks(int t,boolean send)4224 void ImageWindow::setAutoAxesTicks (int t, boolean send)
4225 {
4226 if (!this->node->isA(ClassImageNode))
4227 return ;
4228 ((ImageNode*)this->node)->setAutoAxesTicks (t, send);
4229 }
4230
setAutoAxesXTickLocs(double * t,int size,boolean send)4231 void ImageWindow::setAutoAxesXTickLocs (double *t, int size, boolean send)
4232 {
4233 if (!this->node->isA(ClassImageNode))
4234 return ;
4235 ((ImageNode*)this->node)->setAutoAxesXTickLocs (t, size, send);
4236 }
4237
setAutoAxesYTickLocs(double * t,int size,boolean send)4238 void ImageWindow::setAutoAxesYTickLocs (double *t, int size, boolean send)
4239 {
4240 if (!this->node->isA(ClassImageNode))
4241 return ;
4242 ((ImageNode*)this->node)->setAutoAxesYTickLocs (t, size, send);
4243 }
4244
setAutoAxesZTickLocs(double * t,int size,boolean send)4245 void ImageWindow::setAutoAxesZTickLocs (double *t, int size, boolean send)
4246 {
4247 if (!this->node->isA(ClassImageNode))
4248 return ;
4249 ((ImageNode*)this->node)->setAutoAxesZTickLocs (t, size, send);
4250 }
4251
setAutoAxesXTickLabels(char * value,boolean send)4252 void ImageWindow::setAutoAxesXTickLabels (char *value, boolean send)
4253 {
4254 if (!this->node->isA(ClassImageNode))
4255 return ;
4256 ((ImageNode*)this->node)->setAutoAxesXTickLabels (value, send);
4257 }
4258
setAutoAxesYTickLabels(char * value,boolean send)4259 void ImageWindow::setAutoAxesYTickLabels (char *value, boolean send)
4260 {
4261 if (!this->node->isA(ClassImageNode))
4262 return ;
4263 ((ImageNode*)this->node)->setAutoAxesYTickLabels (value, send);
4264 }
4265
setAutoAxesZTickLabels(char * value,boolean send)4266 void ImageWindow::setAutoAxesZTickLabels (char *value, boolean send)
4267 {
4268 if (!this->node->isA(ClassImageNode))
4269 return ;
4270 ((ImageNode*)this->node)->setAutoAxesZTickLabels (value, send);
4271 }
4272
setAutoAxesAnnotation(char * value,boolean send)4273 void ImageWindow::setAutoAxesAnnotation(char *value, boolean send)
4274 {
4275 if (!this->node->isA(ClassImageNode))
4276 return ;
4277 ((ImageNode*)this->node)->setAutoAxesAnnotation(value, send);
4278 }
4279
setAutoAxesLabels(char * value,boolean send)4280 void ImageWindow::setAutoAxesLabels (char *value, boolean send)
4281 {
4282 if (!this->node->isA(ClassImageNode))
4283 return ;
4284 ((ImageNode*)this->node)->setAutoAxesLabels(value, send);
4285 }
4286
setAutoAxesColors(char * value,boolean send)4287 void ImageWindow::setAutoAxesColors (char *value, boolean send)
4288 {
4289 if (!this->node->isA(ClassImageNode))
4290 return ;
4291 ((ImageNode*)this->node)->setAutoAxesColors(value, send);
4292 }
4293
setAutoAxesFont(char * value,boolean send)4294 void ImageWindow::setAutoAxesFont (char *value, boolean send)
4295 {
4296 if (!this->node->isA(ClassImageNode))
4297 return ;
4298 ((ImageNode*)this->node)->setAutoAxesFont(value, send);
4299 }
4300
getAutoAxesAnnotation(char * sval[])4301 int ImageWindow::getAutoAxesAnnotation (char *sval[])
4302 {
4303 if (!this->node->isA(ClassImageNode))
4304 return 0;
4305 return ((ImageNode*)this->node)->getAutoAxesAnnotation(sval);
4306 }
4307
getAutoAxesLabels(char * sval[])4308 int ImageWindow::getAutoAxesLabels (char *sval[])
4309 {
4310 if (!this->node->isA(ClassImageNode))
4311 return 0;
4312 return ((ImageNode*)this->node)->getAutoAxesLabels(sval);
4313 }
4314
getAutoAxesColors(char * sval[])4315 int ImageWindow::getAutoAxesColors (char *sval[])
4316 {
4317 if (!this->node->isA(ClassImageNode))
4318 return 0;
4319 return ((ImageNode*)this->node)->getAutoAxesColors(sval);
4320 }
4321
getAutoAxesFont(char * sval)4322 int ImageWindow::getAutoAxesFont (char *sval)
4323 {
4324 if (!this->node->isA(ClassImageNode))
4325 return 0;
4326 return ((ImageNode*)this->node)->getAutoAxesFont(sval);
4327 }
4328
getAutoAxesTicks(int * t1,int * t2,int * t3)4329 void ImageWindow::getAutoAxesTicks (int *t1, int *t2, int *t3)
4330 {
4331 if (!this->node->isA(ClassImageNode))
4332 return ;
4333 ((ImageNode*)this->node)->getAutoAxesTicks(t1, t2, t3);
4334 }
4335
getAutoAxesXTickLocs(double ** t,int * size)4336 void ImageWindow::getAutoAxesXTickLocs (double **t, int *size)
4337 {
4338 if (!this->node->isA(ClassImageNode))
4339 return ;
4340 ((ImageNode*)this->node)->getAutoAxesXTickLocs(t, size);
4341 }
4342
getAutoAxesYTickLocs(double ** t,int * size)4343 void ImageWindow::getAutoAxesYTickLocs (double **t, int *size)
4344 {
4345 if (!this->node->isA(ClassImageNode))
4346 return ;
4347 ((ImageNode*)this->node)->getAutoAxesYTickLocs(t, size);
4348 }
4349
getAutoAxesZTickLocs(double ** t,int * size)4350 void ImageWindow::getAutoAxesZTickLocs (double **t, int *size)
4351 {
4352 if (!this->node->isA(ClassImageNode))
4353 return ;
4354 ((ImageNode*)this->node)->getAutoAxesZTickLocs(t, size);
4355 }
4356
getAutoAxesXTickLabels(char * sval[])4357 int ImageWindow::getAutoAxesXTickLabels (char *sval[])
4358 {
4359 if (!this->node->isA(ClassImageNode))
4360 return 0;
4361 return ((ImageNode*)this->node)->getAutoAxesXTickLabels(sval);
4362 }
4363
getAutoAxesYTickLabels(char * sval[])4364 int ImageWindow::getAutoAxesYTickLabels (char *sval[])
4365 {
4366 if (!this->node->isA(ClassImageNode))
4367 return 0;
4368 return ((ImageNode*)this->node)->getAutoAxesYTickLabels(sval);
4369 }
4370
getAutoAxesZTickLabels(char * sval[])4371 int ImageWindow::getAutoAxesZTickLabels (char *sval[])
4372 {
4373 if (!this->node->isA(ClassImageNode))
4374 return 0;
4375 return ((ImageNode*)this->node)->getAutoAxesZTickLabels(sval);
4376 }
4377
getAutoAxesEnable()4378 int ImageWindow::getAutoAxesEnable ()
4379 {
4380 if (!this->node->isA(ClassImageNode))
4381 return 0;
4382 return ((ImageNode*)this->node)->getAutoAxesEnable();
4383 }
4384
getAutoAxesLabelScale()4385 double ImageWindow::getAutoAxesLabelScale ()
4386 {
4387 if (!this->node->isA(ClassImageNode))
4388 return 0.0;
4389 return ((ImageNode*)this->node)->getAutoAxesLabelScale();
4390 }
4391
getAutoAxesTicks(int * t)4392 void ImageWindow::getAutoAxesTicks (int *t)
4393 {
4394 if (!this->node->isA(ClassImageNode))
4395 return ;
4396 ((ImageNode*)this->node)->getAutoAxesTicks(t);
4397 }
4398
getAutoAxesTicksCount()4399 int ImageWindow::getAutoAxesTicksCount ()
4400 {
4401 if (!this->node->isA(ClassImageNode))
4402 return 0;
4403 return ((ImageNode*)this->node)->getAutoAxesTicksCount ();
4404 }
4405
setAutoAxesFrame(boolean state,boolean send)4406 void ImageWindow::setAutoAxesFrame (boolean state, boolean send)
4407 {
4408 if (!this->node->isA(ClassImageNode))
4409 return ;
4410 ((ImageNode*)this->node)->setAutoAxesFrame(state, send);
4411 }
4412
setAutoAxesGrid(boolean state,boolean send)4413 void ImageWindow::setAutoAxesGrid (boolean state, boolean send)
4414 {
4415 if (!this->node->isA(ClassImageNode))
4416 return ;
4417 ((ImageNode*)this->node)->setAutoAxesGrid(state, send);
4418 }
4419
setAutoAxesAdjust(boolean state,boolean send)4420 void ImageWindow::setAutoAxesAdjust (boolean state, boolean send)
4421 {
4422 if (!this->node->isA(ClassImageNode))
4423 return ;
4424 ((ImageNode*)this->node)->setAutoAxesAdjust(state, send);
4425 }
4426
setAutoAxesEnable(int d,boolean send)4427 void ImageWindow::setAutoAxesEnable (int d, boolean send)
4428 {
4429 if (!this->node->isA(ClassImageNode))
4430 return ;
4431 ((ImageNode*)this->node)->setAutoAxesEnable(d, send);
4432 }
4433
setAutoAxesLabelScale(double d,boolean send)4434 void ImageWindow::setAutoAxesLabelScale (double d, boolean send)
4435 {
4436 if (!this->node->isA(ClassImageNode))
4437 return ;
4438 ((ImageNode*)this->node)->setAutoAxesLabelScale(d, send);
4439 }
4440
4441
setWidth(double w)4442 void ImageWindow::setWidth(double w)
4443 {
4444 if (!this->node->isA(ClassImageNode))
4445 return;
4446
4447 if (!this->pushedSinceExec)
4448 {
4449 if (this->state.hardwareRender)
4450 this->sendClientMessage(this->atoms.push_camera);
4451 else
4452 XmPicturePushUndoCamera((XmPictureWidget)this->getCanvas());
4453 this->pushedSinceExec = TRUE;
4454 }
4455
4456 ImageNode *in = (ImageNode*)this->node;
4457 in->setWidth(w);
4458 }
getWidth(double & w)4459 void ImageWindow::getWidth(double &w)
4460 {
4461 if (!this->node->isA(ClassImageNode))
4462 return;
4463
4464 ImageNode *in = (ImageNode*)this->node;
4465
4466 in->getWidth(w);
4467 }
setTo(double * v)4468 void ImageWindow::setTo(double *v)
4469 {
4470 if (!this->node->isA(ClassImageNode))
4471 return;
4472
4473 if (!this->pushedSinceExec)
4474 {
4475 if (this->state.hardwareRender)
4476 this->sendClientMessage(this->atoms.push_camera);
4477 else
4478 XmPicturePushUndoCamera((XmPictureWidget)this->getCanvas());
4479 this->pushedSinceExec = TRUE;
4480 }
4481
4482 ImageNode *in = (ImageNode*)this->node;
4483 in->setTo(v);
4484 }
setFrom(double * v)4485 void ImageWindow::setFrom(double *v)
4486 {
4487 if (!this->node->isA(ClassImageNode))
4488 return;
4489
4490 if (!this->pushedSinceExec)
4491 {
4492 if (this->state.hardwareRender)
4493 this->sendClientMessage(this->atoms.push_camera);
4494 else
4495 XmPicturePushUndoCamera((XmPictureWidget)this->getCanvas());
4496 this->pushedSinceExec = TRUE;
4497 }
4498
4499 ImageNode *in = (ImageNode*)this->node;
4500 in->setFrom(v);
4501 }
setUp(double * v)4502 void ImageWindow::setUp(double *v)
4503 {
4504 if (!this->node->isA(ClassImageNode))
4505 return;
4506
4507 if (!this->pushedSinceExec)
4508 {
4509 if (this->state.hardwareRender)
4510 this->sendClientMessage(this->atoms.push_camera);
4511 else
4512 XmPicturePushUndoCamera((XmPictureWidget)this->getCanvas());
4513 this->pushedSinceExec = TRUE;
4514 }
4515
4516 ImageNode *in = (ImageNode*)this->node;
4517 in->setUp(v);
4518 }
getTo(double * v)4519 void ImageWindow::getTo(double *v)
4520 {
4521 if (!this->node->isA(ClassImageNode))
4522 return;
4523
4524 ImageNode *in = (ImageNode*)this->node;
4525
4526 in->getTo(v);
4527 }
getFrom(double * v)4528 void ImageWindow::getFrom(double *v)
4529 {
4530 if (!this->node->isA(ClassImageNode))
4531 return;
4532
4533 ImageNode *in = (ImageNode*)this->node;
4534
4535 in->getFrom(v);
4536 }
getUp(double * v)4537 void ImageWindow::getUp(double *v)
4538 {
4539 if (!this->node->isA(ClassImageNode))
4540 return;
4541
4542 ImageNode *in = (ImageNode*)this->node;
4543
4544 in->getUp(v);
4545 }
4546
setInteractionMode(DirectInteractionMode mode)4547 boolean ImageWindow::setInteractionMode(DirectInteractionMode mode)
4548 {
4549 return this->setInteractionMode(mode,FALSE);
4550 }
applyPendingInteractionMode()4551 boolean ImageWindow::applyPendingInteractionMode()
4552 {
4553 DirectInteractionMode mode = this->pendingInteractionMode;
4554 if (mode != NONE)
4555 return this->setInteractionMode(mode);
4556 else
4557 return TRUE;
4558 }
4559 #if 00
4560 boolean ImageWindow::activateInteractionMode()
4561 {
4562 DirectInteractionMode mode = this->pendingInteractionMode;
4563 if (mode == NONE)
4564 mode = this->currentInteractionMode;
4565 return this->setInteractionMode(mode,TRUE);
4566 }
4567 #endif
4568
setInteractionMode(DirectInteractionMode mode,boolean ignoreMatchingModes)4569 boolean ImageWindow::setInteractionMode(DirectInteractionMode mode,
4570 boolean ignoreMatchingModes)
4571 {
4572 ImageNode *in = NUL(ImageNode*);
4573 if ((this->node) && (this->node->isA(ClassImageNode)))
4574 in = (ImageNode*)this->node;
4575 boolean success = TRUE;
4576
4577 if (!ignoreMatchingModes && (this->currentInteractionMode == mode))
4578 return TRUE;
4579
4580 if( ((mode == CURSORS) || (mode == ROAM)) && this->state.degenerateBox )
4581 {
4582 WarningMessage("Degenerate bounding box. "
4583 "Can't enter Cursor or Roam modes");
4584 success = FALSE;
4585 mode = NONE;
4586 }
4587
4588 this->pendingInteractionMode = NONE;
4589 if (mode != this->currentInteractionMode) {
4590 DirectInteractionMode oldMode = this->currentInteractionMode;
4591 this->currentInteractionMode = mode;
4592 //
4593 // Reset the mode debore unmanaging sub-form, currentInteractionMode
4594 // must be set at this point.
4595 //
4596 if (this->viewControlDialog)
4597 this->viewControlDialog->resetMode();
4598 //
4599 // Do what we need to leave the old mode.
4600 //
4601 PickNode *curr_pick;
4602 switch (oldMode)
4603 {
4604 case NONE:
4605 break;
4606 case CAMERA:
4607 if (this->viewControlDialog)
4608 this->viewControlDialog->unmanageCameraForm();
4609 break;
4610 case CURSORS:
4611 if (this->viewControlDialog)
4612 this->viewControlDialog->unmanageCursorForm();
4613 break;
4614 case PICK:
4615 if (this->viewControlDialog)
4616 this->viewControlDialog->unmanagePickForm();
4617 //
4618 // We may be unsetting the mode as a result of a window reset,
4619 // which is the result of reading in a new net. When reading
4620 // new nets, the net is cleared so that there are no Pick
4621 // nodes, which results in an ASSERT failure.
4622 //
4623 curr_pick = this->getCurrentPickNode();
4624 if (curr_pick)
4625 curr_pick->pickFrom(NULL);
4626 break;
4627 case NAVIGATE:
4628 if (this->viewControlDialog)
4629 this->viewControlDialog->unmanageNavigationForm();
4630 break;
4631 case ROAM:
4632 if (this->viewControlDialog)
4633 this->viewControlDialog->unmanageRoamForm();
4634 break;
4635 case PANZOOM:
4636 case ROTATE:
4637 case ZOOM:
4638 break;
4639 }
4640 }
4641
4642 switch (mode)
4643 {
4644 case NONE:
4645 if (this->state.hardwareRender)
4646 this->sendClientMessage(this->atoms.stop);
4647
4648 // Set the Picture widget into NULL mode, even if we are doing
4649 // GL render. This is because the Picture widget fields
4650 // key press events for translate speed and rotate speed.
4651 XtVaSetValues(this->getCanvas(),
4652 XmNmode, XmNULL_MODE,
4653 NULL);
4654 if (in) in->setInteractionModeParameter(NONE);
4655 break;
4656 case CAMERA:
4657 if (this->viewControlDialog)
4658 {
4659 this->viewControlDialog->manageCameraForm();
4660 this->viewControlDialog->resetLookDirection();
4661 }
4662 XmPictureAlign((XmPictureWidget)this->getCanvas());
4663
4664 if (this->state.hardwareRender)
4665 this->sendClientMessage(this->atoms.stop);
4666 else
4667 XtVaSetValues(this->getCanvas(),
4668 XmNmode, XmNULL_MODE,
4669 NULL);
4670 if (in) in->setInteractionModeParameter(CAMERA);
4671 break;
4672
4673 case CURSORS:
4674 if (this->viewControlDialog)
4675 {
4676 this->viewControlDialog->manageCursorForm();
4677 this->viewControlDialog->resetLookDirection();
4678 }
4679 XmPictureAlign((XmPictureWidget)this->getCanvas());
4680
4681 if (this->state.hardwareRender)
4682 {
4683 Pixel p[4];
4684 XtVaGetValues(this->getCanvas(),
4685 XmNunselectedInCursorColor, &p[0],
4686 XmNunselectedOutCursorColor, &p[1],
4687 XmNselectedInCursorColor, &p[2],
4688 XmNselectedOutCursorColor, &p[3],
4689 NULL);
4690 long l[4];
4691 l[0] = p[0];
4692 l[1] = p[1];
4693 l[2] = p[2];
4694 l[3] = p[3];
4695
4696 this->sendClientMessage(this->atoms.start_cursor, 4, l);
4697 }
4698 else
4699 XtVaSetValues(this->getCanvas(),
4700 XmNmode, XmCURSOR_MODE,
4701 NULL);
4702
4703 if (!this->selectProbeByInstance(this->currentProbeInstance <= 0 ? 0 :
4704 this->currentProbeInstance)) {
4705 success = FALSE;
4706 this->setInteractionMode(NONE);
4707 if (in) in->setInteractionModeParameter(NONE);
4708 } else
4709 if (in) in->setInteractionModeParameter(CURSORS);
4710 break;
4711
4712 case PICK:
4713 if (!this->selectPickByInstance(this->currentPickInstance <= 0 ? 0 :
4714 this->currentPickInstance)) {
4715 this->setInteractionMode(NONE);
4716 success = FALSE;
4717 break;
4718 }
4719
4720 if (this->viewControlDialog)
4721 this->viewControlDialog->managePickForm();
4722
4723 if ((this->state.pixmap == 0 && !this->state.hardwareRender) ||
4724 (this->state.hardwareWindow == 0 && this->state.hardwareRender)||
4725 (!this->directInteractionAllowed()))
4726 {
4727 // We didn't install it, so save it away and apply it later.
4728 this->pendingInteractionMode = this->currentInteractionMode;
4729 this->currentInteractionMode = NONE;
4730 success = FALSE;
4731 }
4732 else
4733 {
4734 if (this->state.hardwareRender)
4735 {
4736 this->sendClientMessage(this->atoms.start_pick);
4737 }
4738 else
4739 {
4740 XtVaSetValues(this->getCanvas(),
4741 XmNmode, XmPICK_MODE,
4742 NULL);
4743 }
4744 }
4745 if (in) in->setInteractionModeParameter(PICK);
4746 break;
4747
4748 case NAVIGATE:
4749 if (this->viewControlDialog)
4750 this->viewControlDialog->manageNavigationForm();
4751
4752 if (this->state.hardwareRender)
4753 this->sendClientMessage(this->atoms.start_navigate);
4754 /*
4755 * Set the Picture widget into navigate mode, even if we are doing
4756 * GL render. This is because the Picture widget will field
4757 * key press events for translate speed and rotate speed.
4758 */
4759 XtVaSetValues(this->getCanvas(),
4760 XmNmode, XmNAVIGATE_MODE,
4761 NULL);
4762
4763 XmPictureInitializeNavigateMode((XmPictureWidget)this->getCanvas());
4764
4765 if (in) in->setInteractionModeParameter(NAVIGATE);
4766 break;
4767
4768 case PANZOOM:
4769 /*
4770 * Align the navigation direction with the current camera
4771 */
4772 XmPictureAlign((XmPictureWidget)this->getCanvas());
4773
4774 /*
4775 * Indicate that we are looking forward
4776 */
4777 if (this->viewControlDialog)
4778 this->viewControlDialog->resetLookDirection();
4779
4780 if ((this->state.pixmap == 0 && !this->state.hardwareRender) ||
4781 (this->state.hardwareWindow == 0 && this->state.hardwareRender)||
4782 (!this->directInteractionAllowed()))
4783 {
4784 // We didn't install it, so save it away and apply it later.
4785 this->pendingInteractionMode = this->currentInteractionMode;
4786 this->currentInteractionMode = NONE;
4787 success = FALSE;
4788 }
4789 else
4790 {
4791 if (this->state.hardwareRender)
4792 {
4793 this->sendClientMessage(this->atoms.start_panzoom);
4794 }
4795 else
4796 {
4797 XtVaSetValues(this->getCanvas(),
4798 XmNmode, XmPANZOOM_MODE,
4799 NULL);
4800 }
4801 }
4802 if (in) in->setInteractionModeParameter(PANZOOM);
4803 break;
4804
4805 case ROAM:
4806 if (this->state.degenerateBox)
4807 break;
4808
4809 /*
4810 * Align the navigation direction with the current camera
4811 */
4812 XmPictureAlign((XmPictureWidget)this->getCanvas());
4813
4814 /*
4815 * Indicate that we are looking forward
4816 */
4817 if (this->viewControlDialog)
4818 {
4819 this->viewControlDialog->manageRoamForm();
4820 this->viewControlDialog->resetLookDirection();
4821 }
4822
4823 /*
4824 * Change the Globe Display status based on the state of the toggle
4825 * button. This is in case we are switching from H/W->S/W or
4826 * S/W->H/W rendering.
4827 * Set up the Picture widget or send a message to the server.
4828 */
4829 if (!this->state.hardwareRender)
4830 {
4831 XtVaSetValues(this->getCanvas(),
4832 XmNdisplayGlobe, this->state.globeDisplayed,
4833 XmNmode, XmROAM_MODE,
4834 NULL);
4835 }
4836 else
4837 {
4838 long l = this->state.globeDisplayed;
4839 this->sendClientMessage(this->atoms.display_globe, l);
4840 this->sendClientMessage(this->atoms.start_roam);
4841 }
4842 if (in) in->setInteractionModeParameter(ROAM);
4843 break;
4844
4845 case ROTATE:
4846 XmPictureAlign((XmPictureWidget)this->getCanvas());
4847 if (this->viewControlDialog)
4848 this->viewControlDialog->resetLookDirection();
4849
4850 // put up the globe
4851 if (!this->state.hardwareRender)
4852 {
4853 XtVaSetValues(this->getCanvas(),
4854 XmNdisplayGlobe, this->state.globeDisplayed,
4855 NULL);
4856 }
4857 else
4858 {
4859 long l = this->state.globeDisplayed;
4860 this->sendClientMessage(this->atoms.display_globe, l);
4861 }
4862 // If we are in direct interaction mode(...), enter the mode.
4863 if ((this->state.pixmap == 0 && !this->state.hardwareRender) ||
4864 (this->state.hardwareWindow == 0 && this->state.hardwareRender)||
4865 (!this->directInteractionAllowed()))
4866 {
4867 // We didn't install it, so save it away and apply it later.
4868 this->pendingInteractionMode = this->currentInteractionMode;
4869 this->currentInteractionMode = NONE;
4870 success = FALSE;
4871 }
4872 else
4873 {
4874 if (this->state.hardwareRender)
4875 {
4876 this->sendClientMessage(this->atoms.start_rotate);
4877 }
4878 else
4879 {
4880 XtVaSetValues(this->getCanvas(),
4881 XmNmode, XmROTATION_MODE,
4882 NULL);
4883 }
4884 }
4885 if (in) in->setInteractionModeParameter(ROTATE);
4886 break;
4887
4888 case ZOOM:
4889 /*
4890 * Align the navigation direction with the current camera
4891 */
4892 XmPictureAlign((XmPictureWidget)this->getCanvas());
4893
4894 /*
4895 * Indicate that we are looking forward
4896 */
4897 if (this->viewControlDialog)
4898 this->viewControlDialog->resetLookDirection();
4899
4900 if ((this->state.pixmap == 0 && !this->state.hardwareRender) ||
4901 (this->state.hardwareWindow == 0 && this->state.hardwareRender)||
4902 (!this->directInteractionAllowed()))
4903 {
4904 // We didn't install it, so save it away and apply it later.
4905 this->pendingInteractionMode = this->currentInteractionMode;
4906 this->currentInteractionMode = NONE;
4907 success = FALSE;
4908 }
4909 else
4910 {
4911 if (this->state.hardwareRender)
4912 {
4913 this->sendClientMessage(this->atoms.start_zoom);
4914 }
4915 else
4916 {
4917 XtVaSetValues(this->getCanvas(),
4918 XmNmode, XmZOOM_MODE,
4919 NULL);
4920 }
4921 }
4922 if (in) in->setInteractionModeParameter(ZOOM);
4923 break;
4924 }
4925 return success;
4926 }
getInteractionMode()4927 DirectInteractionMode ImageWindow::getInteractionMode()
4928 {
4929 //
4930 // Arguably, this should always return the currently installed
4931 // interaction mode (currentInteractionMode), but adding
4932 // pendingInteractionMode which reset currentInteractionMode to
4933 // NONE when setInteractionMode() fails, changed the semantics
4934 // of this function. It used to return the last value passed to
4935 // setInteractionMode() which WAS in currentInteractionMode, but
4936 // now is not always. So, to keep the semantics the same, we return
4937 // pendingInteractionMode if not NONE.
4938 //
4939 // NOTE: the fact that the old semantics may have not been very useful
4940 // there may actually be the source of a bug in these semantics.
4941 //
4942 DirectInteractionMode mode = this->pendingInteractionMode;
4943 if (mode == NONE)
4944 mode = this->currentInteractionMode;
4945 return mode;
4946 }
4947
beginExecution()4948 void ImageWindow::beginExecution()
4949 {
4950 this->DXWindow::beginExecution();
4951 boolean execOnChange = theDXApplication->getExecCtl()->inExecOnChange();
4952 if (execOnChange)
4953 XmPictureExecutionState((XmPictureWidget)this->getCanvas(), True);
4954
4955 //
4956 // disable the menu options for changing depth becuase if the user
4957 // changes one during execution, the exec crashes (we pulled the
4958 // rug out from under him.) The options will be turned back on
4959 // appropriately because I added configureImageDepth() in endExecution.
4960 // and in standBy (for eoc mode).
4961 if (this->imageDepth8Cmd) this->imageDepth8Cmd->deactivate();
4962 if (this->imageDepth12Cmd) this->imageDepth12Cmd->deactivate();
4963 if (this->imageDepth15Cmd) this->imageDepth15Cmd->deactivate();
4964 if (this->imageDepth16Cmd) this->imageDepth16Cmd->deactivate();
4965 if (this->imageDepth24Cmd) this->imageDepth24Cmd->deactivate();
4966 if (this->imageDepth32Cmd) this->imageDepth32Cmd->deactivate();
4967 }
standBy()4968 void ImageWindow::standBy()
4969 {
4970 this->DXWindow::standBy();
4971
4972 boolean execOnChange = theDXApplication->getExecCtl()->inExecOnChange();
4973 if (this->state.hardwareRender)
4974 {
4975 long l = execOnChange? 1: 0;
4976 this->sendClientMessage(this->atoms.execute_on_change, l);
4977 }
4978 if (execOnChange)
4979 XmPictureExecutionState((XmPictureWidget)this->getCanvas(), False);
4980
4981 //
4982 // reset the greying of the image depth buttons because they're all turned
4983 // grey when beginning an execution. Changing depth during an execution
4984 // really pulls the rug out from under the exec.
4985 //
4986 this->configureImageDepthMenu();
4987 }
endExecution()4988 void ImageWindow::endExecution()
4989 {
4990 this->DXWindow::endExecution();
4991
4992 boolean execOnChange = theDXApplication->getExecCtl()->inExecOnChange();
4993 if (this->state.hardwareRender)
4994 {
4995 long l = execOnChange? 1: 0;
4996 this->sendClientMessage(this->atoms.execute_on_change, l);
4997 }
4998 if (execOnChange)
4999 XmPictureExecutionState((XmPictureWidget)this->getCanvas(), False);
5000
5001 //
5002 // reset the greying of the image depth buttons because they're all turned
5003 // grey when beginning an execution. Changing depth during an execution
5004 // really pulls the rug out from under the exec.
5005 //
5006 this->configureImageDepthMenu();
5007 }
5008
newCamera(int image_width,int image_height)5009 void ImageWindow::newCamera(int image_width, int image_height)
5010 {
5011 this->state.width = image_width;
5012 this->state.height = image_height;
5013
5014 this->pushedSinceExec = FALSE;
5015
5016 this->newCanvasImage();
5017 }
5018
newCamera(double box[4][3],double aamat[4][4],double * from,double * to,double * up,int image_width,int image_height,double width,boolean perspective,double viewAngle)5019 void ImageWindow::newCamera(double box[4][3], double aamat[4][4],
5020 double *from, double *to, double *up,
5021 int image_width, int image_height, double width,
5022 boolean perspective, double viewAngle)
5023 {
5024 this->newCamera(image_width, image_height);
5025
5026 if (!this->node->isA(ClassImageNode))
5027 return;
5028
5029 XmBasis basis;
5030 ImageNode *in = (ImageNode *)this->node;
5031
5032 basis.Bw[3][0] = box[3][0];
5033 basis.Bw[2][0] = box[2][0];
5034 basis.Bw[1][0] = box[1][0];
5035 basis.Bw[0][0] = box[0][0];
5036
5037 basis.Bw[3][1] = box[3][1];
5038 basis.Bw[2][1] = box[2][1];
5039 basis.Bw[1][1] = box[1][1];
5040 basis.Bw[0][1] = box[0][1];
5041
5042 basis.Bw[3][2] = box[3][2];
5043 basis.Bw[2][2] = box[2][2];
5044 basis.Bw[1][2] = box[1][2];
5045 basis.Bw[0][2] = box[0][2];
5046
5047 basis.Bw[3][3] = basis.Bs[3][3] = 1;
5048 basis.Bw[2][3] = basis.Bs[2][3] = 1;
5049 basis.Bw[1][3] = basis.Bs[1][3] = 1;
5050 basis.Bw[0][3] = basis.Bs[0][3] = 1;
5051
5052 // Setup the vector value depending on whether it's to, from, or up.
5053 // Setup the width/heights.
5054
5055 // Update the picture widget's idea of the camera.
5056 //
5057 // XmPictureNewCamera checks to see if we have a degenerate bounding box.
5058 // It also completely updates the Picture widget's camera information.
5059 //
5060 if (!XmPictureNewCamera((XmPictureWidget) this->getCanvas(),
5061 basis, aamat,
5062 from[0], from[1], from[2],
5063 to[0], to[1], to[2],
5064 up[0], up[1], up[2],
5065 image_width, image_height, width,
5066 in->useAutoAxes(), perspective, viewAngle))
5067 {
5068 this->state.degenerateBox = TRUE;
5069 /*
5070 * See if we are in Roam or Cursor mode, and, if we are, kick out.
5071 */
5072 if (this->currentInteractionMode == ROAM ||
5073 this->currentInteractionMode == CURSORS)
5074 {
5075 WarningMessage("Degenerate bounding box: Roam and 3D Cursors disabled.");
5076 this->setInteractionMode(NONE);
5077 if (this->viewControlDialog)
5078 this->viewControlDialog->resetMode();
5079 }
5080
5081 if (this->viewControlDialog)
5082 this->viewControlDialog->newCamera(
5083 from, to, up,
5084 image_width, image_height, width,
5085 perspective, viewAngle);
5086 }
5087 else
5088 {
5089 this->cameraInitialized = TRUE;
5090
5091 this->state.degenerateBox = FALSE;
5092 if (this->viewControlDialog)
5093 this->viewControlDialog->newCamera(
5094 from, to, up,
5095 image_width, image_height, width,
5096 perspective, viewAngle);
5097 if (XmPictureUndoable((XmPictureWidget)this->getCanvas()))
5098 this->getUndoCmd()->activate();
5099 else
5100 this->getUndoCmd()->deactivate();
5101 if (XmPictureRedoable((XmPictureWidget)this->getCanvas()))
5102 this->getRedoCmd()->activate();
5103 else
5104 this->getRedoCmd()->deactivate();
5105 }
5106 }
5107
undoCamera()5108 void ImageWindow::undoCamera()
5109 {
5110 if (this->viewControlDialog)
5111 this->viewControlDialog->resetSetView();
5112
5113 if (this->state.hardwareRender)
5114 {
5115 this->sendClientMessage(this->atoms.undo_camera);
5116 }
5117 else
5118 {
5119 double to[3];
5120 double from[3];
5121 double up[3];
5122 double width;
5123 boolean projection;
5124 double viewAngle;
5125
5126 int tmp;
5127 if(!XmPictureGetUndoCamera((XmPictureWidget)this->getCanvas(),
5128 &to[0], &to[1], &to[2],
5129 &from[0], &from[1], &from[2],
5130 &up[0], &up[1], &up[2],
5131 &width, &tmp,
5132 &viewAngle))
5133 return;
5134
5135 // pc build changed boolean from int to unsigned char
5136 projection = tmp;
5137
5138 ImageNode *in = (ImageNode *)this->node;
5139 in->setTo(to, FALSE);
5140 in->setFrom(from, FALSE);
5141 in->setUp(up, FALSE);
5142 in->setWidth(width, FALSE);
5143 in->setProjection(projection, FALSE);
5144 in->setViewAngle(viewAngle, FALSE);
5145
5146 int image_width;
5147 int image_height;
5148 in->getResolution(image_width, image_height);
5149
5150 if (this->viewControlDialog)
5151 {
5152 this->viewControlDialog->resetSetView();
5153 this->viewControlDialog->newCamera(
5154 from, to, up,
5155 image_width, image_height, width,
5156 projection, viewAngle);
5157 }
5158
5159 in->sendValues(FALSE);
5160
5161 boolean execOnChange = theDXApplication->getExecCtl()->inExecOnChange();
5162 if (!execOnChange)
5163 theDXApplication->getExecCtl()->executeOnce();
5164 }
5165
5166 /*
5167 * Align the navigation direction with the current camera
5168 */
5169 XmPictureAlign((XmPictureWidget)this->getCanvas());
5170
5171 /*
5172 * Indicate that we are looking forward
5173 * Indicate that we are looking at front
5174 */
5175 if (this->viewControlDialog)
5176 {
5177 this->viewControlDialog->resetLookDirection();
5178 this->viewControlDialog->resetSetView();
5179 }
5180
5181 }
redoCamera()5182 void ImageWindow::redoCamera()
5183 {
5184 if (this->viewControlDialog)
5185 this->viewControlDialog->resetSetView();
5186
5187 if (this->state.hardwareRender)
5188 {
5189 this->sendClientMessage(this->atoms.redo_camera);
5190 }
5191 else
5192 {
5193 double to[3];
5194 double from[3];
5195 double up[3];
5196 double width;
5197 boolean projection;
5198 double viewAngle;
5199
5200 int tmp;
5201 XmPictureGetRedoCamera((XmPictureWidget)this->getCanvas(),
5202 &to[0], &to[1], &to[2],
5203 &from[0], &from[1], &from[2],
5204 &up[0], &up[1], &up[2],
5205 &width, &tmp,
5206 &viewAngle);
5207
5208 projection = tmp;
5209
5210 ImageNode *in = (ImageNode *)this->node;
5211 in->setTo(to, FALSE);
5212 in->setFrom(from, FALSE);
5213 in->setUp(up, FALSE);
5214 in->setWidth(width, FALSE);
5215 in->setProjection(projection, FALSE);
5216 in->setViewAngle(viewAngle, FALSE);
5217
5218 int image_width;
5219 int image_height;
5220 in->getResolution(image_width, image_height);
5221
5222 if (this->viewControlDialog)
5223 {
5224 this->viewControlDialog->resetSetView();
5225 this->viewControlDialog->newCamera(
5226 from, to, up,
5227 image_width, image_height, width,
5228 projection, viewAngle);
5229 }
5230
5231 in->sendValues(FALSE);
5232
5233 boolean execOnChange = theDXApplication->getExecCtl()->inExecOnChange();
5234 if (!execOnChange)
5235 theDXApplication->getExecCtl()->executeOnce();
5236 }
5237 }
resetCamera()5238 void ImageWindow::resetCamera()
5239 {
5240 /*
5241 * Save the current camera so undo will work as expected
5242 */
5243 if (this->state.hardwareRender)
5244 {
5245 if (!this->pushedSinceExec)
5246 {
5247 this->sendClientMessage(this->atoms.push_camera);
5248 this->pushedSinceExec = TRUE;
5249 }
5250 this->sendClientMessage(this->atoms.image_reset);
5251 }
5252 else
5253 {
5254 /*
5255 * If the picture widget does not yet have an image,
5256 * don't push the undo camera onto the stack
5257 */
5258 Pixmap pixmap;
5259 XtVaGetValues(this->getCanvas(), XmNpicturePixmap, &pixmap, NULL);
5260 if (pixmap != XmUNSPECIFIED_PIXMAP)
5261 {
5262 if (!this->pushedSinceExec)
5263 {
5264 XmPicturePushUndoCamera((XmPictureWidget)this->getCanvas());
5265 this->pushedSinceExec = TRUE;
5266 }
5267 }
5268 }
5269
5270 /*
5271 * Align the navigation direction with the current camera
5272 */
5273 XmPictureAlign((XmPictureWidget)this->getCanvas());
5274
5275 /*
5276 * Indicate that we are looking forward
5277 * Indicate that we are looking at front
5278 */
5279 if (this->viewControlDialog)
5280 {
5281 this->viewControlDialog->resetLookDirection();
5282 this->viewControlDialog->resetSetView();
5283 }
5284
5285 /*
5286 * Reset up, and trigger an execution.
5287 */
5288 ImageNode *in = (ImageNode *)this->node;
5289 double v[3];
5290 v[0] = 0; v[1] = 1; v[2] = 0;
5291 in->setUp(v, FALSE);
5292 in->enableVector(FALSE,FALSE);// This will not result in a sendValues().
5293 in->sendValues(FALSE);
5294
5295 DXExecCtl *ctl = theDXApplication->getExecCtl();
5296 #if NOT_YET
5297 if (ctl->isVcrExecuting()) {
5298 ctl->pauseVcr();
5299 ctl->getExecCtl()->executeOnce();
5300 ctl->continueVcr();
5301 } else
5302 #endif
5303 if (ctl->assignmentRequiresExecution())
5304 ctl->executeOnce();
5305 }
5306
setView(ViewDirection dir)5307 boolean ImageWindow::setView(ViewDirection dir)
5308 {
5309 if (!this->directInteractionAllowed())
5310 return FALSE;
5311
5312 long widgetsDirection = TOP;
5313
5314 switch (dir) {
5315 case VIEW_NONE:
5316 return TRUE;
5317
5318 case VIEW_TOP:
5319 widgetsDirection = TOP;
5320 break;
5321 case VIEW_BOTTOM:
5322 widgetsDirection = BOTTOM;
5323 break;
5324 case VIEW_FRONT:
5325 widgetsDirection = FRONT;
5326 break;
5327 case VIEW_BACK:
5328 widgetsDirection = BACK;
5329 break;
5330 case VIEW_LEFT:
5331 widgetsDirection = LEFT;
5332 break;
5333 case VIEW_RIGHT:
5334 widgetsDirection = RIGHT;
5335 break;
5336 case VIEW_DIAGONAL:
5337 widgetsDirection = DIAGONAL;
5338 break;
5339 case VIEW_OFF_TOP:
5340 widgetsDirection = OFF_TOP;
5341 break;
5342 case VIEW_OFF_BOTTOM:
5343 widgetsDirection = OFF_BOTTOM;
5344 break;
5345 case VIEW_OFF_FRONT:
5346 widgetsDirection = OFF_FRONT;
5347 break;
5348 case VIEW_OFF_BACK:
5349 widgetsDirection = OFF_BACK;
5350 break;
5351 case VIEW_OFF_LEFT:
5352 widgetsDirection = OFF_LEFT;
5353 break;
5354 case VIEW_OFF_RIGHT:
5355 widgetsDirection = OFF_RIGHT;
5356 break;
5357 case VIEW_OFF_DIAGONAL:
5358 widgetsDirection = OFF_DIAGONAL;
5359 break;
5360 }
5361
5362 if (this->state.hardwareRender)
5363 {
5364 if (!this->pushedSinceExec)
5365 {
5366 this->sendClientMessage(this->atoms.push_camera);
5367 this->pushedSinceExec = TRUE;
5368 }
5369 this->sendClientMessage(this->atoms.set_view, widgetsDirection);
5370 }
5371 else
5372 {
5373 if (!this->pushedSinceExec)
5374 {
5375 XmPicturePushUndoCamera((XmPictureWidget)this->getCanvas());
5376 this->pushedSinceExec = TRUE;
5377 }
5378 double from[3];
5379 double up[3];
5380 XmPictureSetView((XmPictureWidget)this->getCanvas(), widgetsDirection,
5381 &from[0], &from[1], &from[2],
5382 &up[0], &up[1], &up[2]);
5383
5384 ImageNode *in = (ImageNode*)this->node;
5385 in->setUp(up, FALSE);
5386 in->setFrom(from, TRUE);
5387 if (theDXApplication->getExecCtl()->assignmentRequiresExecution())
5388 theDXApplication->getExecCtl()->executeOnce();
5389 #if NOT_YET
5390 // This code doesn't seem to have the same problem as resetCamera().
5391 #endif
5392 }
5393
5394 return TRUE;
5395 }
5396
setLook(LookDirection dir)5397 boolean ImageWindow::setLook(LookDirection dir)
5398 {
5399 if (!this->directInteractionAllowed())
5400 return FALSE;
5401 int mdir = XmLOOK_FORWARD;
5402 double angle = 0;
5403 const double OurPI = 3.14159;
5404
5405 switch (dir) {
5406 case LOOK_FORWARD:
5407 mdir = XmLOOK_FORWARD;
5408 break;
5409 case LOOK_LEFT45:
5410 mdir = XmLOOK_LEFT;
5411 angle = OurPI/4;
5412 break;
5413 case LOOK_RIGHT45:
5414 mdir = XmLOOK_RIGHT;
5415 angle = OurPI/4;
5416 break;
5417 case LOOK_UP45:
5418 mdir = XmLOOK_UP;
5419 angle = OurPI/4;
5420 break;
5421 case LOOK_DOWN45:
5422 mdir = XmLOOK_DOWN;
5423 angle = OurPI/4;
5424 break;
5425 case LOOK_LEFT90:
5426 mdir = XmLOOK_LEFT;
5427 angle = OurPI/2;
5428 break;
5429 case LOOK_RIGHT90:
5430 mdir = XmLOOK_RIGHT;
5431 angle = OurPI/2;
5432 break;
5433 case LOOK_UP90:
5434 mdir = XmLOOK_UP;
5435 angle = OurPI/2;
5436 break;
5437 case LOOK_DOWN90:
5438 mdir = XmLOOK_DOWN;
5439 angle = OurPI/2;
5440 break;
5441 case LOOK_BACKWARD:
5442 mdir = XmLOOK_BACKWARD;
5443 break;
5444 case LOOK_ALIGN:
5445 if (this->state.hardwareRender)
5446 // Send 6 by convention with exec
5447 this->sendClientMessage(this->atoms.navigate_look_at, (long)6);
5448 XmPictureAlign((XmPictureWidget)this->getCanvas());
5449 if (this->viewControlDialog)
5450 this->viewControlDialog->resetLookDirection();
5451
5452 return TRUE;
5453 }
5454
5455 if (!this->pushedSinceExec)
5456 {
5457 if (this->state.hardwareRender)
5458 this->sendClientMessage(this->atoms.push_camera);
5459 else
5460 XmPicturePushUndoCamera((XmPictureWidget)this->getCanvas());
5461 this->pushedSinceExec = TRUE;
5462 }
5463
5464 if (this->state.hardwareRender)
5465 {
5466 float tmpfloat = angle;
5467 long l[5];
5468 l[0] = mdir;
5469 memcpy((void*)&l[1], (void*)&tmpfloat, sizeof(float));
5470 this->sendClientMessage(this->atoms.navigate_look_at, 2, l);
5471 }
5472 double to[3];
5473 double from[3];
5474 double up[3];
5475 double width;
5476 XmPictureChangeLookAt((XmPictureWidget)this->getCanvas(), mdir, angle,
5477 &to[0], &to[1], &to[2],
5478 &from[0], &from[1], &from[2],
5479 &up[0], &up[1], &up[2],
5480 &width);
5481
5482 ImageNode *in = (ImageNode*)this->node;
5483 if (!this->state.hardwareRender)
5484 {
5485 in->setTo(to, FALSE);
5486 in->setFrom(from, FALSE);
5487 in->setUp(up, TRUE);
5488 }
5489 else
5490 {
5491 in->setTo(to, FALSE);
5492 in->setFrom(from, FALSE);
5493 in->setUp(up, FALSE);
5494 in->sendValuesQuietly();
5495 }
5496
5497 return TRUE;
5498 }
5499
setConstraint(ConstraintDirection dir)5500 boolean ImageWindow::setConstraint(ConstraintDirection dir)
5501 {
5502 if (!this->directInteractionAllowed())
5503 return FALSE;
5504 int hwconstraint = 0; // Hardware constraint
5505 int pwconstraint = 0; // picture widget constraint
5506
5507 switch (dir) {
5508 case CONSTRAINT_NONE:
5509 hwconstraint = 0;
5510 pwconstraint = XmCONSTRAIN_NONE;
5511 break;
5512 case CONSTRAINT_X:
5513 hwconstraint = 1;
5514 pwconstraint = XmCONSTRAIN_X;
5515 break;
5516 case CONSTRAINT_Y:
5517 hwconstraint = 2;
5518 pwconstraint = XmCONSTRAIN_Y;
5519 break;
5520 case CONSTRAINT_Z:
5521 hwconstraint = 3;
5522 pwconstraint = XmCONSTRAIN_Z;
5523 break;
5524 }
5525
5526 if (this->state.hardwareRender)
5527 {
5528 this->sendClientMessage(this->atoms.cursor_constraint,
5529 (long)hwconstraint);
5530 }
5531
5532 XtVaSetValues(this->getCanvas(),
5533 XmNconstrainCursor, pwconstraint, NULL);
5534
5535 return TRUE;
5536 }
5537
getConstraint()5538 ConstraintDirection ImageWindow::getConstraint()
5539 {
5540 ConstraintDirection dir = CONSTRAINT_NONE;
5541 int pwconstraint;
5542
5543 XtVaGetValues(this->getCanvas(),
5544 XmNconstrainCursor, &pwconstraint, NULL);
5545
5546 switch (pwconstraint) {
5547 case XmCONSTRAIN_NONE:
5548 dir = CONSTRAINT_NONE;
5549 break;
5550 case XmCONSTRAIN_X:
5551 dir = CONSTRAINT_X;
5552 break;
5553 case XmCONSTRAIN_Y:
5554 dir = CONSTRAINT_Y;
5555 break;
5556 case XmCONSTRAIN_Z:
5557 dir = CONSTRAINT_Z;
5558 break;
5559 }
5560 return dir;
5561 }
5562
setSoftware(boolean sw)5563 void ImageWindow::setSoftware(boolean sw)
5564 {
5565 long glob;
5566 Pixel p[4];
5567 long l[4];
5568
5569 if (!this->node->isA(ClassImageNode))
5570 return;
5571
5572 boolean oldSw;
5573 this->getSoftware(oldSw);
5574 if (oldSw != sw)
5575 this->switchingSoftware = TRUE;
5576
5577 if (!sw)
5578 {
5579 this->upWireframeCmd->activate();
5580 this->downWireframeCmd->activate();
5581
5582 switch (this->currentInteractionMode)
5583 {
5584 case CURSORS:
5585 XtVaGetValues(this->getCanvas(),
5586 XmNunselectedInCursorColor, &p[0],
5587 XmNunselectedOutCursorColor, &p[1],
5588 XmNselectedInCursorColor, &p[2],
5589 XmNselectedOutCursorColor, &p[3],
5590 NULL);
5591 l[0] = p[0];
5592 l[1] = p[1];
5593 l[2] = p[2];
5594 l[3] = p[3];
5595
5596 this->sendClientMessage(this->atoms.start_cursor, 4, l);
5597 break;
5598
5599 case PICK:
5600 this->sendClientMessage(this->atoms.start_pick);
5601 break;
5602
5603 case NAVIGATE:
5604 this->sendClientMessage(this->atoms.start_navigate);
5605 break;
5606
5607 case PANZOOM:
5608 this->sendClientMessage(this->atoms.start_panzoom);
5609 break;
5610
5611 case ROAM:
5612 glob = this->state.globeDisplayed;
5613 this->sendClientMessage(this->atoms.display_globe, glob);
5614 this->sendClientMessage(this->atoms.start_roam);
5615 break;
5616
5617 case ZOOM:
5618 this->sendClientMessage(this->atoms.start_zoom);
5619 break;
5620
5621 case ROTATE:
5622 glob = this->state.globeDisplayed;
5623 this->sendClientMessage(this->atoms.display_globe, glob);
5624 this->sendClientMessage(this->atoms.start_rotate);
5625 break;
5626
5627 case NONE:
5628 case CAMERA:
5629 default:
5630 break;
5631 }
5632 }
5633 else
5634 {
5635 //
5636 // Reset the approx mode back to none if it was wireframe. Use
5637 // this->node->setApprox, not this->setApproximation so that we can
5638 // set send to FALSE.
5639 ImageNode *in = (ImageNode *)this->node;
5640 ApproxMode mode;
5641 this->getApproximation(TRUE, mode);
5642 if(mode == APPROX_WIREFRAME)
5643 in->setApprox(TRUE, "\"none\"", FALSE);
5644 this->upWireframeCmd->deactivate();
5645
5646 this->getApproximation(FALSE, mode);
5647 if(mode == APPROX_WIREFRAME)
5648 in->setApprox(FALSE, "\"none\"", FALSE);
5649 this->downWireframeCmd->deactivate();
5650 }
5651
5652 ImageNode *in = (ImageNode *)this->node;
5653 in->enableSoftwareRendering(sw, (oldSw != sw));
5654
5655 this->configureImageDepthMenu();
5656
5657 if (this->renderingOptionsDialog)
5658 this->renderingOptionsDialog->resetApproximations();
5659 }
getSoftware(boolean & sw)5660 void ImageWindow::getSoftware(boolean &sw)
5661 {
5662 DisplayNode *n = (DisplayNode*)this->node;
5663 ASSERT(n);
5664 ASSERT(((Node*)n)->isA(ClassDisplayNode));
5665 sw = n->useSoftwareRendering();
5666 }
setApproximation(boolean up,ApproxMode mode)5667 void ImageWindow::setApproximation(boolean up, ApproxMode mode)
5668 {
5669 if (!this->node->isA(ClassImageNode))
5670 return;
5671 ImageNode *in = (ImageNode *)this->node;
5672 switch (mode) {
5673 case APPROX_NONE:
5674 in->setApprox(up, "\"none\"");
5675 break;
5676 case APPROX_WIREFRAME:
5677 in->setApprox(up, "\"wireframe\"");
5678 break;
5679 case APPROX_DOTS:
5680 in->setApprox(up, "\"dots\"");
5681 break;
5682 case APPROX_BOX:
5683 in->setApprox(up, "\"box\"");
5684 break;
5685 }
5686 }
getApproximation(boolean up,ApproxMode & mode)5687 void ImageWindow::getApproximation(boolean up, ApproxMode &mode)
5688 {
5689 if (!this->node->isA(ClassImageNode))
5690 return;
5691 ImageNode *in = (ImageNode *)this->node;
5692 const char *s;
5693 in->getApprox(up, s);
5694 if (EqualString(s, "\"none\""))
5695 mode = APPROX_NONE;
5696 else if (EqualString(s, "\"wireframe\""))
5697 mode = APPROX_WIREFRAME;
5698 else if (EqualString(s, "\"dots\""))
5699 mode = APPROX_DOTS;
5700 else if (EqualString(s, "\"box\""))
5701 mode = APPROX_BOX;
5702 else
5703 mode = (ApproxMode)-9999;
5704 }
setDensity(boolean up,int density)5705 void ImageWindow::setDensity(boolean up, int density)
5706 {
5707 if (!this->node->isA(ClassImageNode))
5708 return;
5709 ImageNode *in = (ImageNode *)this->node;
5710 in->setDensity(up, density, TRUE);
5711 }
getDensity(boolean up,int & density)5712 void ImageWindow::getDensity(boolean up, int &density)
5713 {
5714 if (!this->node->isA(ClassImageNode))
5715 return;
5716 ImageNode *in = (ImageNode *)this->node;
5717 in->getDensity(up, density);
5718 }
5719
setCurrentProbe(int i)5720 boolean ImageWindow::setCurrentProbe(int i)
5721 {
5722 if (! this->selectProbeByInstance(i))
5723 return FALSE;
5724
5725 if (this->viewControlDialog)
5726 this->viewControlDialog->setCurrentProbeByInstance(i);
5727
5728 return TRUE;
5729 }
5730
setCurrentPick(int i)5731 boolean ImageWindow::setCurrentPick(int i)
5732 {
5733 if (! this->selectPickByInstance(i))
5734 return FALSE;
5735
5736 if (this->viewControlDialog)
5737 this->viewControlDialog->setCurrentPickByInstance(i);
5738
5739 return TRUE;
5740 }
5741
wait4GLAcknowledge()5742 void ImageWindow::wait4GLAcknowledge()
5743 {
5744
5745 XEvent e;
5746
5747 e.xclient.message_type = ((Atom) None); // Undefined atom
5748 while(e.xclient.message_type != this->atoms.gl_shutdown)
5749 {
5750 XCheckTypedWindowEvent(theApplication->getDisplay(),
5751 XtWindow(this->getCanvas()),
5752 ClientMessage,
5753 &e);
5754 }
5755 this->state.hardwareRenderExists = FALSE;
5756 }
5757
sendClientMessage(Atom atom,int num,float * floats)5758 void ImageWindow::sendClientMessage(Atom atom, int num, float *floats)
5759 {
5760 XEvent e;
5761 if (!this->state.hardwareRenderExists || this->state.hardwareWindow == 0)
5762 return;
5763
5764 e.type = ClientMessage;
5765 e.xclient.format = 32;
5766 e.xclient.message_type = atom;
5767 int i;
5768 for (i = 0; i < num && i < 5; ++i)
5769 memcpy(&e.xclient.data.l[i], &floats[i], sizeof(float));
5770 for (; i < 5; ++i)
5771 e.xclient.data.l[i] = 0;
5772
5773 XSendEvent(XtDisplay(this->getRootWidget()), this->state.hardwareWindow,
5774 True, 0, &e);
5775 }
sendClientMessage(Atom atom,int num,long * longs)5776 void ImageWindow::sendClientMessage(Atom atom, int num, long *longs)
5777 {
5778 XEvent e;
5779 if (!this->state.hardwareRenderExists || this->state.hardwareWindow == 0)
5780 return;
5781
5782 e.type = ClientMessage;
5783 e.xclient.format = 32;
5784 e.xclient.message_type = atom;
5785 int i;
5786 for (i = 0; i < num && i < 5; ++i)
5787 e.xclient.data.l[i] = longs[i];
5788 for (; i < 5; ++i)
5789 e.xclient.data.l[i] = 0;
5790
5791 XSendEvent(XtDisplay(this->getRootWidget()), this->state.hardwareWindow,
5792 True, 0, &e);
5793 }
sendClientMessage(Atom atom,int num,short * shorts)5794 void ImageWindow::sendClientMessage(Atom atom, int num, short *shorts)
5795 {
5796 XEvent e;
5797 if (!this->state.hardwareRenderExists || this->state.hardwareWindow == 0)
5798 return;
5799
5800 e.type = ClientMessage;
5801 e.xclient.format = 16;
5802 e.xclient.message_type = atom;
5803 int i;
5804 for (i = 0; i < num && i < 10; ++i)
5805 e.xclient.data.s[i] = shorts[i];
5806 for (; i < 10; ++i)
5807 e.xclient.data.s[i] = 0;
5808
5809 XSendEvent(XtDisplay(this->getRootWidget()), this->state.hardwareWindow,
5810 True, 0, &e);
5811 }
sendClientMessage(Atom atom,int num,char * chars)5812 void ImageWindow::sendClientMessage(Atom atom, int num, char *chars)
5813 {
5814 XEvent e;
5815 if (!this->state.hardwareRenderExists || this->state.hardwareWindow == 0)
5816 return;
5817
5818 e.type = ClientMessage;
5819 e.xclient.format = 8;
5820 e.xclient.message_type = atom;
5821 int i;
5822 for (i = 0; i < num && i < 20; ++i)
5823 e.xclient.data.b[i] = chars[i];
5824 for (; i < 20; ++i)
5825 e.xclient.data.b[i] = 0;
5826
5827 XSendEvent(XtDisplay(this->getRootWidget()), this->state.hardwareWindow,
5828 True, 0, &e);
5829 }
5830
5831 //
5832 // Probe Management
5833 //
addProbe(Node * probe)5834 void ImageWindow::addProbe(Node* probe)
5835 {
5836 this->getModeCursorsCmd()->activate();
5837 if (this->viewControlDialog)
5838 this->viewControlDialog->createProbePulldown();
5839 }
5840
deleteProbe(Node * probe)5841 void ImageWindow::deleteProbe(Node* probe)
5842 {
5843 if (!this->network->containsClassOfNode(ClassProbeNode))
5844 {
5845 this->getModeCursorsCmd()->deactivate();
5846 if (this->getInteractionMode() == CURSORS)
5847 {
5848 this->setInteractionMode(NONE);
5849 if (this->viewControlDialog)
5850 this->viewControlDialog->resetMode();
5851 }
5852 this->currentProbeInstance = -1;
5853 }
5854 else
5855 {
5856 if(probe->getInstanceNumber() == this->currentProbeInstance)
5857 this->selectProbeByInstance(0);
5858 if (this->viewControlDialog)
5859 this->viewControlDialog->createProbePulldown();
5860 }
5861 }
5862
changeProbe(Node *)5863 void ImageWindow::changeProbe(Node*)
5864 {
5865 if (this->viewControlDialog)
5866 this->viewControlDialog->createProbePulldown();
5867 }
5868
getCurrentProbeNode()5869 ProbeNode *ImageWindow::getCurrentProbeNode()
5870 {
5871 ProbeNode *p;
5872 if (this->currentProbeInstance <= 0)
5873 return NULL;
5874
5875 p = (ProbeNode*)this->getNodeByInstance(ClassProbeNode,"Probe",
5876 this->currentProbeInstance);
5877 if (!p)
5878 p = (ProbeNode*)this->getNodeByInstance(ClassProbeNode,"ProbeList",
5879 this->currentProbeInstance);
5880 return p;
5881 }
5882
5883
selectProbeByInstance(int i)5884 boolean ImageWindow::selectProbeByInstance(int i)
5885 {
5886
5887 long l[5];
5888 float tmpfloat;
5889 double *darray;
5890 double **vlist;
5891 const char *strValue;
5892 int tuple;
5893 ProbeNode *probe;
5894
5895 probe = (ProbeNode*)this->getNodeByInstance(ClassProbeNode,"Probe",i);
5896 if (!probe)
5897 probe = (ProbeNode*)this->getNodeByInstance(ClassProbeNode,"ProbeList",
5898 i);
5899 if (!probe)
5900 return FALSE;
5901
5902 Parameter *param = probe->getOutput();
5903
5904 this->currentProbeInstance = probe->getInstanceNumber();
5905
5906 if(EqualString(probe->getNameString(),"Probe")
5907 AND param->hasValue())
5908 {
5909 double *v = new double[3];
5910 v[0] = param->getVectorComponentValue(1);
5911 v[1] = param->getVectorComponentValue(2);
5912 v[2] = param->getVectorComponentValue(3);
5913 if(NOT this->state.hardwareRender)
5914 {
5915 XmPictureLoadCursors((XmPictureWidget)this->canvas, 1, &v);
5916 }
5917 else
5918 {
5919
5920 l[0] = -1;
5921 l[1] = XmPCR_DELETE;
5922 this->sendClientMessage(this->atoms.cursor_change, 2, l);
5923
5924 l[0] = 0;
5925 l[1] = XmPCR_CREATE;
5926 tmpfloat = v[0];
5927 memcpy(&l[2], &tmpfloat, sizeof(float));
5928 tmpfloat = v[1];
5929 memcpy(&l[3], &tmpfloat, sizeof(float));
5930 tmpfloat = v[2];
5931 memcpy(&l[4], &tmpfloat, sizeof(float));
5932
5933 this->sendClientMessage(this->atoms.cursor_change, 5, l);
5934 }
5935 delete v;
5936 }
5937 else if(EqualString(probe->getNameString(),"ProbeList")
5938 AND param->hasValue())
5939 {
5940 int i;
5941 int j;
5942
5943 strValue = probe->getOutputValueString(1);
5944
5945 int n = 0;
5946 int count = DXValue::GetDoublesFromList(strValue,
5947 DXType::VectorListType,
5948 &darray, &tuple);
5949 vlist = (double**)new double*[count];
5950 for(i = 0; i < count; i++)
5951 {
5952 vlist[i] = new double[tuple];
5953 for(j = 0; j < tuple; j++)
5954 vlist[i][j] = darray[n++];
5955 }
5956 delete darray;
5957
5958 if(NOT this->state.hardwareRender)
5959 {
5960 XmPictureLoadCursors((XmPictureWidget)this->canvas,count,vlist);
5961 }
5962 else {
5963 l[0] = -1;
5964 l[1] = XmPCR_DELETE;
5965 this->sendClientMessage(this->atoms.cursor_change, 2, l);
5966
5967 l[1] = XmPCR_CREATE;
5968 for (i = 0; i < count; i++)
5969 {
5970 l[0] = i;
5971 tmpfloat = vlist[i][0];
5972 memcpy(&l[2], &tmpfloat, sizeof(float));
5973 tmpfloat = vlist[i][1];
5974 memcpy(&l[3], &tmpfloat, sizeof(float));
5975 tmpfloat = vlist[i][2];
5976 memcpy(&l[4], &tmpfloat, sizeof(float));
5977
5978 this->sendClientMessage(this->atoms.cursor_change, 5, l);
5979 }
5980 }
5981 for(i = 0; i < count; i++)
5982 delete vlist[i];
5983 delete vlist;
5984 }
5985 else {
5986 if(NOT this->state.hardwareRender)
5987 XmPictureDeleteCursors((XmPictureWidget)this->canvas, -1);
5988 else
5989 {
5990 l[0] = -1;
5991 l[1] = XmPCR_DELETE;
5992 this->sendClientMessage(this->atoms.cursor_change, 2, l);
5993 }
5994 }
5995
5996 return TRUE;
5997 }
5998
addPick(Node * pick)5999 void ImageWindow::addPick(Node* pick)
6000 {
6001 this->getModePickCmd()->activate();
6002 if (this->viewControlDialog)
6003 this->viewControlDialog->createPickPulldown();
6004 }
6005
deletePick(Node * pick)6006 void ImageWindow::deletePick(Node* pick)
6007 {
6008 if (!this->network->containsClassOfNode(ClassPickNode))
6009 {
6010 this->getModePickCmd()->deactivate();
6011 if (this->getInteractionMode() == PICK)
6012 {
6013 this->setInteractionMode(NONE);
6014 if (this->viewControlDialog)
6015 this->viewControlDialog->resetMode();
6016 }
6017 this->currentPickInstance = -1;
6018 }
6019 else
6020 {
6021 if(pick->getInstanceNumber() == this->currentPickInstance)
6022 this->selectPickByInstance(0);
6023 if (this->viewControlDialog)
6024 this->viewControlDialog->createPickPulldown();
6025 }
6026 }
6027
changePick(Node *)6028 void ImageWindow::changePick(Node*)
6029 {
6030 if (this->viewControlDialog)
6031 this->viewControlDialog->createPickPulldown();
6032 }
6033
getCurrentPickNode()6034 PickNode *ImageWindow::getCurrentPickNode()
6035 {
6036 if (this->currentPickInstance <= 0)
6037 return NULL;
6038 else
6039 return (PickNode*)this->getNodeByInstance(ClassPickNode,"Pick",
6040 this->currentPickInstance);
6041 }
6042
getNodeByInstance(const char * classname,const char * name,int instance)6043 Node *ImageWindow::getNodeByInstance(const char *classname, const char *name,
6044 int instance)
6045 {
6046 Node *node = NULL;
6047 if (instance <= 0) {
6048 //
6049 // Find the pick with the lowest instance number.
6050 //
6051 List *l = this->network->makeClassifiedNodeList(classname, FALSE);
6052 if (l) {
6053 int mininst = 0;
6054 Node *first=NULL;
6055 ListIterator iter(*l);
6056 while ( (node = (Node*)iter.getNext()) ) {
6057 int newinst = node->getInstanceNumber();
6058 if ((mininst == 0) || (newinst < mininst)) {
6059 mininst = newinst;
6060 first = node;
6061 }
6062 }
6063 node = first;
6064 delete l;
6065 }
6066 } else {
6067 node = this->getNetwork()->getNode(name,instance);
6068 }
6069 return node;
6070 }
6071
selectPickByInstance(int i)6072 boolean ImageWindow::selectPickByInstance(int i)
6073 {
6074 PickNode *pick;
6075 PickNode *curr_pick = this->getCurrentPickNode();
6076
6077 pick = (PickNode*)this->getNodeByInstance(ClassPickNode,"Pick",i);
6078 if (!pick)
6079 return FALSE;
6080
6081 if (curr_pick && curr_pick != pick)
6082 curr_pick->pickFrom(NULL);
6083
6084 this->currentPickInstance = pick->getInstanceNumber();;
6085
6086 ListIterator images(*this->network->getImageList());
6087 ImageWindow *w;
6088 while ( (w = (ImageWindow*)images.getNext()) )
6089 if (w != this && w->getInteractionMode() == PICK &&
6090 w->getCurrentPickNode() == pick)
6091 w->setInteractionMode(NONE);
6092
6093 pick->pickFrom(this->node);
6094
6095 return TRUE;
6096 }
6097
setBackgroundColor(const char * color)6098 boolean ImageWindow::setBackgroundColor(const char *color)
6099 {
6100 ASSERT(this->node->isA(ClassImageNode));
6101 ImageNode *n = (ImageNode*)this->node;
6102 n->setBackgroundColor(color);
6103 return TRUE;
6104 }
6105
updateBGColorDialog(const char * color)6106 boolean ImageWindow::updateBGColorDialog(const char *color)
6107 {
6108 if (this->backgroundColorDialog)
6109 this->backgroundColorDialog->installEditorText(color);
6110 return TRUE;
6111 }
6112
6113
updateThrottleDialog(double v)6114 boolean ImageWindow::updateThrottleDialog(double v)
6115 {
6116 if (this->throttleDialog)
6117 this->throttleDialog->installThrottleValue(v);
6118 return TRUE;
6119 }
6120
getBackgroundColor()6121 const char *ImageWindow::getBackgroundColor()
6122 {
6123 ASSERT(this->node->isA(ClassImageNode));
6124 ImageNode *n = (ImageNode*)this->node;
6125 const char *c;
6126 n->getBackgroundColor(c);
6127 return c;
6128 }
6129
postBackgroundColorDialog()6130 boolean ImageWindow::postBackgroundColorDialog()
6131 {
6132 if (!this->backgroundColorDialog)
6133 this->backgroundColorDialog = new SetBGColorDialog(this);
6134 this->backgroundColorDialog->post();
6135 return TRUE;
6136 }
6137
enableRecord(boolean enable)6138 boolean ImageWindow::enableRecord(boolean enable)
6139 {
6140 ASSERT(this->node->isA(ClassImageNode));
6141 ImageNode *n = (ImageNode*)this->node;
6142 n->setRecordEnable (RECORD_ENABLE_NO_RERENDER);
6143 return TRUE;
6144 }
setRecordFile(const char * file)6145 boolean ImageWindow::setRecordFile(const char *file)
6146 {
6147 ASSERT(this->node->isA(ClassImageNode));
6148 ImageNode *n = (ImageNode*)this->node;
6149 n->setRecordFile(file);
6150 return TRUE;
6151 }
6152
setRecordFormat(const char * format)6153 boolean ImageWindow::setRecordFormat(const char *format)
6154 {
6155 ASSERT(this->node->isA(ClassImageNode));
6156 ImageNode *n = (ImageNode*)this->node;
6157 n->setRecordFormat(format);
6158 return TRUE;
6159 }
6160
getRecordFile()6161 const char *ImageWindow::getRecordFile()
6162 {
6163 ASSERT(this->node->isA(ClassImageNode));
6164 ImageNode *n = (ImageNode*)this->node;
6165
6166 const char *file;
6167 n->getRecordFile(file);
6168
6169 return file;
6170 }
getRecordFormat()6171 const char *ImageWindow::getRecordFormat()
6172 {
6173 ASSERT(this->node->isA(ClassImageNode));
6174 ImageNode *n = (ImageNode*)this->node;
6175
6176 const char *format;
6177 n->getRecordFormat(format);
6178
6179 return format;
6180 }
6181
getRecordResolution(int & x,int & y)6182 void ImageWindow::getRecordResolution(int &x, int &y)
6183 {
6184 ASSERT(this->node->isA(ClassImageNode));
6185 ImageNode *n = (ImageNode*)this->node;
6186
6187 n->getRecordResolution(x, y);
6188 }
6189
getRecordAspect()6190 double ImageWindow::getRecordAspect()
6191 {
6192 ASSERT(this->node->isA(ClassImageNode));
6193 ImageNode *n = (ImageNode*)this->node;
6194
6195 double aspect;
6196 n->getRecordAspect(aspect);
6197
6198 return aspect;
6199 }
6200
useRecord()6201 boolean ImageWindow::useRecord()
6202 {
6203 int recenab;
6204 ASSERT(this->node->isA(ClassImageNode));
6205 ImageNode *n = (ImageNode*)this->node;
6206 n->getRecordEnable (recenab);
6207 return recenab == NO_RECORD_ENABLE;
6208
6209 }
clearFrameBufferOverlay()6210 void ImageWindow::clearFrameBufferOverlay()
6211 {
6212
6213 Window overlayWID;
6214
6215 XtVaGetValues(this->getCanvas(),
6216 XmNoverlayWid, &overlayWID,
6217 XmNframeBuffer, &this->state.frameBuffer,
6218 NULL);
6219
6220 if (this->state.frameBuffer)
6221 {
6222 XSetWindowAttributes attributes;
6223 attributes.background_pixel =
6224 WhitePixelOfScreen(XtScreen(this->getCanvas())) + 1;
6225 XChangeWindowAttributes(XtDisplay(this->getCanvas()),
6226 overlayWID, CWBackPixel, &attributes);
6227 XClearWindow(XtDisplay(this->getCanvas()), overlayWID);
6228 }
6229
6230 }
newCanvasImage()6231 void ImageWindow::newCanvasImage()
6232 {
6233 if (++this->state.imageCount == 1)
6234 {
6235 this->clearFrameBufferOverlay();
6236
6237 if (this->node->isA(ClassImageNode))
6238 {
6239 this->modeNoneCmd->activate();
6240 this->modeCameraCmd->activate();
6241 if (this->node &&
6242 this->network->containsClassOfNode(ClassProbeNode))
6243 this->modeCursorsCmd->activate();
6244 if (this->node && this->network->containsClassOfNode(ClassPickNode))
6245 this->modePickCmd->activate();
6246 this->modeNavigateCmd->activate();
6247 this->modePanZoomCmd->activate();
6248 this->modeRoamCmd->activate();
6249 this->modeRotateCmd->activate();
6250 this->modeZoomCmd->activate();
6251 this->configureModeMenu();
6252 }
6253 }
6254 this->state.pixmap = XtUnspecifiedPixmap;
6255 Position x;
6256 Position y;
6257 if (this->state.frameBuffer)
6258 {
6259 XtVaGetValues(XtParent(XtParent(this->getCanvas())),
6260 XmNx, &x, XmNy, &y, NULL);
6261 }
6262
6263 Dimension w = this->state.width;
6264 Dimension h = this->state.height;
6265 this->state.resizeFromServer = TRUE;
6266 XtVaSetValues(this->getCanvas(), XmNwidth, w, XmNheight, h, NULL);
6267 this->state.resizeFromServer = FALSE;
6268
6269 if (this->state.frameBuffer)
6270 {
6271 Position new_x;
6272 Position new_y;
6273 if (this->state.frameBuffer)
6274 {
6275 XtVaGetValues(XtParent(XtParent(this->getCanvas())),
6276 XmNx, &new_x, XmNy, &new_y, NULL);
6277 }
6278 if (new_x != x || new_y != y)
6279 {
6280 DisplayNode *dn = (DisplayNode*)this->node;
6281 dn->notifyWhereChange(TRUE);
6282 }
6283 }
6284
6285 if (this->getInteractionMode() == PICK)
6286 {
6287 XmPictureDeleteCursors((XmPictureWidget)this->getCanvas(), -1);
6288 PickNode *n = this->getCurrentPickNode();
6289 if (n)
6290 n->resetCursor();
6291 }
6292
6293 boolean sw;
6294 this->getSoftware(sw);
6295 if (this->switchingSoftware && !sw)
6296 {
6297 XmPictureAlign((XmPictureWidget)this->getCanvas());
6298 if (this->viewControlDialog)
6299 this->viewControlDialog->resetLookDirection();
6300 DirectInteractionMode m = this->getInteractionMode();
6301 this->setInteractionMode(NONE);
6302 this->setInteractionMode(m);
6303 this->setConstraint(this->getConstraint());
6304 this->undoCmd->deactivate();
6305 this->redoCmd->deactivate();
6306 this->switchingSoftware = FALSE;
6307 } else {
6308 this->applyPendingInteractionMode();
6309 }
6310 }
6311
ImageWindow_TrackFrameBufferEH(Widget,XtPointer clientData,XEvent * event,Boolean * continue_to_dispatch)6312 extern "C" void ImageWindow_TrackFrameBufferEH(
6313 Widget,
6314 XtPointer clientData,
6315 XEvent *event,
6316 Boolean *continue_to_dispatch)
6317 {
6318 ImageWindow *image = (ImageWindow *)clientData;
6319
6320 image->trackFrameBuffer(event, continue_to_dispatch);
6321 }
6322
trackFrameBuffer(XEvent * event,Boolean * continue_to_dispatch)6323 void ImageWindow::trackFrameBuffer(XEvent *event, Boolean *continue_to_dispatch)
6324 {
6325 XWindowAttributes attributes;
6326 boolean execOnChange = theDXApplication->getExecCtl()->inExecOnChange();
6327 DisplayNode *dn = (DisplayNode*)this->node;
6328
6329 *continue_to_dispatch = True;
6330
6331 switch (event->type) {
6332 case ReparentNotify:
6333 Window window;
6334 this->state.parent.window = event->xreparent.parent;
6335
6336 XSelectInput(XtDisplay(this->getRootWidget()),
6337 this->state.parent.window,
6338 StructureNotifyMask);
6339 XGetWindowAttributes(XtDisplay(this->getRootWidget()),
6340 this->state.parent.window,
6341 &attributes);
6342
6343 XTranslateCoordinates
6344 (XtDisplay(this->getRootWidget()),
6345 this->state.parent.window,
6346 RootWindowOfScreen(XtScreen(this->getRootWidget())),
6347 attributes.x,
6348 attributes.y,
6349 &this->state.parent.x,
6350 &this->state.parent.y,
6351 &window);
6352
6353 this->state.parent.width = attributes.width;
6354 this->state.parent.height = attributes.height;
6355
6356 /*
6357 * If connected, assign a new display string and cause another
6358 * execution of the network to occur.
6359 */
6360 dn->notifyWhereChange(TRUE);
6361
6362 if (!execOnChange)
6363 theDXApplication->getExecCtl()->executeOnce();
6364 break;
6365
6366 case ConfigureNotify: {
6367
6368 //
6369 // Draw a 4 pixel wide/high rectangle at right/bottom of 24 bit
6370 // window to hide the schmutz. Actually, calc the width/height
6371 // of the schmutz rectangle base on the position of the Picture
6372 // widget relative to the root.
6373 //
6374 if(this->canvas &&
6375 XtIsRealized(this->canvas) &&
6376 this->node &&
6377 this->state.imageCount > 0)
6378 {
6379
6380 int canvas_root_x, canvas_root_y;
6381
6382 XTranslateCoordinates
6383 (XtDisplay(this->canvas),
6384 XtWindow(this->canvas),
6385 RootWindowOfScreen(XtScreen(this->getRootWidget())),
6386 0,
6387 0,
6388 &canvas_root_x,
6389 &canvas_root_y,
6390 &window);
6391 int schmutz_width, schmutz_height;
6392 schmutz_width = canvas_root_x%4;
6393 schmutz_height = canvas_root_y%4;
6394
6395 Window owid;
6396 XtVaGetValues(this->canvas, XmNoverlayWid, &owid, NULL);
6397 XUnmapWindow(XtDisplay(this->canvas), owid);
6398 XSync(XtDisplay(this->canvas), False);
6399 XGetWindowAttributes(XtDisplay(this->canvas),
6400 XtWindow(this->canvas),
6401 &attributes);
6402
6403 unsigned long valuemask=0;
6404
6405 GC gc = XCreateGC(XtDisplay(this->canvas), XtWindow(this->canvas),
6406 valuemask, NULL);
6407 XSetForeground(XtDisplay(this->canvas), gc, (Pixel)0);
6408 if(schmutz_width > 0)
6409 XFillRectangle(XtDisplay(this->canvas),
6410 XtWindow(this->canvas),
6411 gc,
6412 attributes.width-schmutz_width,
6413 0,
6414 schmutz_width,
6415 attributes.height);
6416
6417 if(schmutz_height > 0)
6418 XFillRectangle(XtDisplay(this->canvas),
6419 XtWindow(this->canvas),
6420 gc,
6421 0,
6422 attributes.height-schmutz_height,
6423 attributes.width,
6424 schmutz_height);
6425 XFlush(XtDisplay(this->canvas));
6426 XFreeGC(XtDisplay(this->canvas), gc);
6427 XMapWindow(XtDisplay(this->canvas), owid);
6428 XFlush(XtDisplay(this->canvas));
6429 }
6430
6431 if(!this->state.parent.window) return;
6432
6433 /*
6434 * Get the new (x,y) coordinates.
6435 */
6436 XGetWindowAttributes(XtDisplay(this->getRootWidget()),
6437 this->state.parent.window,
6438 &attributes);
6439
6440 XTranslateCoordinates
6441 (XtDisplay(this->getRootWidget()),
6442 this->state.parent.window,
6443 RootWindowOfScreen(XtScreen(this->getRootWidget())),
6444 attributes.x,
6445 attributes.y,
6446 &attributes.x,
6447 &attributes.y,
6448 &window);
6449
6450 /*
6451 * Save the old x, y values and set new x, y values.
6452 */
6453 int old_x = this->state.parent.x;
6454 int old_y = this->state.parent.y;
6455 this->state.parent.x = attributes.x;
6456 this->state.parent.y = attributes.y;
6457
6458 /*
6459 * If width or height has changed, let the image window
6460 * resize handler take care of this problem (which will
6461 * also take care of the (x,y) change as well).
6462 */
6463 if (this->state.parent.width != event->xconfigure.width ||
6464 this->state.parent.height != event->xconfigure.height)
6465 {
6466 this->state.parent.width = event->xconfigure.width;
6467 this->state.parent.height = event->xconfigure.height;
6468 }
6469
6470 /*
6471 * If the new (x,y) coordinates are identical to previous
6472 * coordinates, return.
6473 */
6474 if (this->state.parent.x == old_x &&
6475 this->state.parent.y == old_y)
6476 {
6477 break;
6478 }
6479
6480 if (this->node == NULL)
6481 break;
6482
6483 /*
6484 * If connected, assign a new display string and cause another
6485 * execution of the network to occur.
6486 */
6487 dn->notifyWhereChange(TRUE);
6488
6489 if (!execOnChange)
6490 theDXApplication->getExecCtl()->executeOnce();
6491 break;
6492 }
6493
6494
6495 default:
6496 break;
6497 }
6498 }
6499
HandleExposures(XEvent * event,void * clientData)6500 boolean ImageWindow::HandleExposures(XEvent *event, void *clientData)
6501 {
6502 ImageWindow *iw = (ImageWindow *)clientData;
6503 return iw->handleExposures(event);
6504 }
6505
handleExposures(XEvent * event)6506 boolean ImageWindow::handleExposures(XEvent*event)
6507 {
6508 XtVaSetValues(this->getCanvas(),
6509 XmNoverlayExposure, True,
6510 NULL);
6511 return TRUE;
6512 }
6513
setTranslateSpeed(double s)6514 void ImageWindow::setTranslateSpeed(double s)
6515 {
6516 this->state.navigateTranslateSpeed = s;
6517 if (this->state.hardwareRender)
6518 {
6519 float tmpfloat = s;
6520 this->sendClientMessage(this->atoms.motion, tmpfloat);
6521 }
6522 else
6523 {
6524 XtVaSetValues(this->getCanvas(), XmNtranslateSpeed, (int)s, NULL);
6525 }
6526 if (this->viewControlDialog)
6527 this->viewControlDialog->setNavigateSpeed(s);
6528 }
6529
setRotateSpeed(double s)6530 void ImageWindow::setRotateSpeed(double s)
6531 {
6532 this->state.navigateRotateSpeed = s;
6533 if (this->state.hardwareRender)
6534 {
6535 float tmpfloat = s;
6536 this->sendClientMessage(this->atoms.pivot, tmpfloat);
6537 }
6538 else
6539 {
6540 XtVaSetValues(this->getCanvas(), XmNrotateSpeed, (int)s, NULL);
6541 }
6542 if (this->viewControlDialog)
6543 this->viewControlDialog->setNavigatePivot(s);
6544 }
6545
getTranslateSpeed()6546 double ImageWindow::getTranslateSpeed()
6547 {
6548 return this->state.navigateTranslateSpeed;
6549 }
6550
getRotateSpeed()6551 double ImageWindow::getRotateSpeed()
6552 {
6553 return this->state.navigateRotateSpeed;
6554 }
6555
serverDisconnected()6556 void ImageWindow::serverDisconnected()
6557 {
6558 this->resetWindow();
6559 this->DXWindow::serverDisconnected();
6560 }
6561
resetWindow()6562 void ImageWindow::resetWindow()
6563 {
6564
6565 //
6566 // c1orrang1 File/New causes a resetWindow which could happen while in
6567 // hardware mode. If so, we'ld better tell the exec about it.
6568 //
6569 if ((this->state.hardwareRenderExists) && (theDXApplication->getPacketIF()))
6570 {
6571 this->sendClientMessage(this->atoms.gl_destroy_window);
6572 this->wait4GLAcknowledge();
6573 }
6574
6575 this->state.imageCount = 0;
6576
6577 XtVaSetValues(this->getCanvas(),
6578 XmNpicturePixmap, XmUNSPECIFIED_PIXMAP,
6579 NULL);
6580
6581 this->setInteractionMode(NONE);
6582 if (this->viewControlDialog)
6583 this->viewControlDialog->setSensitivity(FALSE);
6584
6585 XmPictureReset((XmPictureWidget)this->getCanvas());
6586
6587 Window overlayWID;
6588 XtVaGetValues(this->getCanvas(),
6589 XmNoverlayWid, &overlayWID,
6590 XmNframeBuffer, &this->state.frameBuffer,
6591 NULL);
6592
6593 if (this->state.frameBuffer)
6594 {
6595
6596 XSetWindowAttributes attributes;
6597 attributes.background_pixel =
6598 BlackPixelOfScreen(XtScreen(this->getCanvas()));
6599 XChangeWindowAttributes(XtDisplay(this->getCanvas()),
6600 overlayWID, CWBackPixel, &attributes);
6601 XClearWindow(XtDisplay(this->getCanvas()), overlayWID);
6602 }
6603
6604 this->undoCmd->deactivate();
6605 this->redoCmd->deactivate();
6606 this->modeNoneCmd->deactivate();
6607 this->modeCameraCmd->deactivate();
6608 this->modeCursorsCmd->deactivate();
6609 this->modePickCmd->deactivate();
6610 this->modeNavigateCmd->deactivate();
6611 this->modePanZoomCmd->deactivate();
6612 this->modeRoamCmd->deactivate();
6613 this->modeRotateCmd->deactivate();
6614 this->modeZoomCmd->deactivate();
6615 this->configureModeMenu();
6616
6617 if (this->state.pixmap)
6618 XDeleteProperty(
6619 XtDisplay(this->getCanvas()),
6620 XtWindow(this->getCanvas()),
6621 this->atoms.dx_pixmap_id);
6622 this->state.pixmap = XtUnspecifiedPixmap;
6623 this->state.hardwareRender = FALSE;
6624 this->state.hardwareRenderExists = FALSE;
6625 XSync(XtDisplay(this->getCanvas()), False);
6626
6627 DisplayNode *in = (DisplayNode*)this->node;
6628 if (in)
6629 in->notifyWhereChange(FALSE);
6630 }
6631
changeDepth(int depth)6632 void ImageWindow::changeDepth(int depth)
6633 {
6634 int canvas_depth;
6635 ImageNode *in = (ImageNode*)this->node;
6636 Dimension width, height;
6637 int new_depth = depth;
6638 Boolean frame_buffer;
6639 boolean sw;
6640
6641 //
6642 // If we have a HW renderer, we need to get rid of it now, while we
6643 // still have the window to send the ClientMessage.
6644 //
6645 if(this->state.hardwareRenderExists)
6646 {
6647 this->sendClientMessage(this->atoms.gl_destroy_window);
6648 this->wait4GLAcknowledge();
6649 }
6650 this->getSoftware(sw);
6651 if(sw)
6652 this->allowDirectInteraction(FALSE);
6653
6654 XtVaGetValues(this->getCanvas(),
6655 XmNdepth, &canvas_depth,
6656 XmNframeBuffer, &frame_buffer,
6657 NULL);
6658 if(canvas_depth != depth)
6659 {
6660 #if 0
6661 Boolean sup8, sup12, sup16, sup24, sup32;
6662 XtVaGetValues(this->getCanvas(),
6663 XmN8supported, &sup8,
6664 XmN12supported, ¹2,
6665 XmN16supported, ¹6,
6666 XmN24supported, ²4,
6667 XmN32supported, ³2,
6668 NULL);
6669 #endif
6670 //
6671 // If an unsupported depth was requested, revert to the default depth.
6672 // If the resulting depth is the default depth, we are done, so return.
6673 //
6674 if(this->adjustDepth(new_depth))
6675 if(new_depth == canvas_depth) return;
6676
6677 //
6678 // Get the old width and height so we can restore it
6679 //
6680 XtVaGetValues(this->getCanvas(),
6681 XmNwidth, &width,
6682 XmNheight, &height,
6683 NULL);
6684 //
6685 // Destroy the old picture widget, since it is not possible to
6686 // dynamically change the depth of a widget.
6687 //
6688 XtVaSetValues(this->form, XmNresizePolicy, XmRESIZE_NONE, NULL);
6689 //
6690 // UnSetting XmNpicturePixmap is really a strange thing to do to
6691 // a widget your're about to destroy, but if you look carefully, you'll
6692 // see that at some future point, after destruction, the widget will
6693 // try to repaint itself. In doing so it will use the old pixmap which
6694 // no longer exists and it will generate an X protocol error. This
6695 // defies logic. To test this, comment out this SetValues, then change
6696 // depth, turn on rotation, and resize the image window. Then load
6697 // just the cfg file.
6698 //
6699 XtVaSetValues (this->getCanvas(), XmNpicturePixmap, XmUNSPECIFIED_PIXMAP, NULL);
6700 XtDestroyWidget(this->getCanvas());
6701
6702 //
6703 // Create the new picture widget, with the desired depth.
6704 //
6705 this->canvas =
6706 XtVaCreateManagedWidget
6707 ("canvas",
6708 xmPictureWidgetClass,
6709 this->form,
6710 XmNsendMotion, False,
6711 XmNmode, XmNULL_MODE,
6712 XmNshowRotatingBBox, False,
6713 XmNglobeRadius, 10,
6714 XmNleftAttachment, XmATTACH_FORM,
6715 XmNrightAttachment, XmATTACH_FORM,
6716 XmNtopAttachment, XmATTACH_FORM,
6717 XmNbottomAttachment, XmATTACH_FORM,
6718 XmNdepth, depth,
6719 XmNwidth, width,
6720 XmNheight, height,
6721 XmNhighlightPixmap, XmUNSPECIFIED_PIXMAP,
6722 NULL);
6723
6724 this->completePictureCreation();
6725
6726 XtVaSetValues(this->form, XmNresizePolicy, XmRESIZE_ANY, NULL);
6727 //
6728 // Install all of the callbacks...
6729 //
6730 this->installCallbacks();
6731
6732 //
6733 // Blow away the old gc, since the depth does no match any more.
6734 // remember the old interaction mode and state of the rotation globe.
6735 // Must turn off the globe before resetting old_mode because the picture
6736 // widget can't cope otherwise. FIXME
6737 //
6738 DirectInteractionMode old_mode = this->getInteractionMode();
6739
6740 if (this->state.globeDisplayed)
6741 this->setDisplayGlobe();
6742
6743 if(this->state.gc)
6744 XFreeGC(XtDisplay(this->canvas),this->state.gc);
6745 this->state.gc = NULL;
6746 this->setInteractionMode((DirectInteractionMode)NONE);
6747 if(in)
6748 in->setDepth(depth);
6749
6750 //
6751 // restore the old interaction mode.
6752 //
6753 this->pendingInteractionMode = old_mode;
6754 }
6755
6756 this->configureImageDepthMenu();
6757
6758 }
adjustDepth(int & depth)6759 boolean ImageWindow::adjustDepth(int &depth)
6760 {
6761 ImageNode *in = (ImageNode*)this->node;
6762 Boolean sup8, sup12, sup15, sup16, sup24, sup32;
6763 int new_depth;
6764
6765 XtVaGetValues(this->getCanvas(),
6766 XmN8supported, &sup8,
6767 XmN12supported, ¹2,
6768 XmN15supported, ¹5,
6769 XmN16supported, ¹6,
6770 XmN24supported, ²4,
6771 XmN32supported, ³2,
6772 NULL);
6773 //
6774 // If an unsupported depth was requested revert to the default depth.
6775 // If the current depth is the default depth, we are done, so return.
6776 //
6777 if( ((depth == 8) && !sup8) ||
6778 ((depth == 12) && !sup12) ||
6779 ((depth == 15) && !sup16) ||
6780 ((depth == 16) && !sup16) ||
6781 ((depth == 24) && !sup24) ||
6782 ((depth == 32) && !sup32) )
6783 {
6784 new_depth = DefaultDepth(theApplication->getDisplay(),
6785 DefaultScreen(theApplication->getDisplay()));
6786
6787 #if 0
6788 char msg[256];
6789 if (new_depth < depth) {
6790 sprintf (msg, "An image depth of %d is not supported on this hardware. The default image depth (%d) will be used.", depth, new_depth);
6791 theDXApplication->getMessageWindow()->addWarning (msg);
6792 }
6793 #endif
6794 // Inform the Node
6795 if(in)
6796 in->setDepth(new_depth);
6797 depth = new_depth;
6798 return TRUE;
6799 }
6800 return FALSE;
6801 }
6802
6803 //
6804 // Save the image with the current(or default) name.
6805 //
saveImage()6806 void ImageWindow::saveImage()
6807 {
6808
6809
6810 }
6811
postSaveImageDialog()6812 boolean ImageWindow::postSaveImageDialog()
6813 {
6814 if(NOT this->saveImageDialog)
6815 this->saveImageDialog = new SaveImageDialog
6816 (this->getRootWidget(), (ImageNode*)this->node, this->commandScope);
6817
6818 this->saveImageDialog->post();
6819 // Force Image's Translations onto saveImageDialog here.
6820 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6821 this->saveOption->getRootWidget(), "ArmAndActivate");
6822 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6823 this->saveImageOption->getRootWidget(), "ArmAndActivate");
6824 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6825 this->printImageOption->getRootWidget(), "ArmAndActivate");
6826 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6827 this->closeOption->getRootWidget(), "ArmAndActivate");
6828 if(this->openAllControlPanelsOption)
6829 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6830 this->openAllControlPanelsOption->getRootWidget(), "ArmAndActivate");
6831 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6832 this->openAllColormapEditorsOption->getRootWidget(), "ArmAndActivate");
6833 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6834 this->messageWindowOption->getRootWidget(), "ArmAndActivate");
6835 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6836 this->undoOption->getRootWidget(), "ArmAndActivate");
6837 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6838 this->redoOption->getRootWidget(), "ArmAndActivate");
6839 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6840 this->resetOption->getRootWidget(), "ArmAndActivate");
6841 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6842 this->executeOnceOption->getRootWidget(), "ArmAndActivate");
6843 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6844 this->executeOnChangeOption->getRootWidget(), "ArmAndActivate");
6845 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6846 this->endExecutionOption->getRootWidget(), "ArmAndActivate");
6847
6848 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6849 this->modeCameraOption->getRootWidget(), "ArmAndActivate");
6850 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6851 this->modeCursorsOption->getRootWidget(), "ArmAndActivate");
6852 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6853 this->modePickOption->getRootWidget(), "ArmAndActivate");
6854 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6855 this->modeNavigateOption->getRootWidget(), "ArmAndActivate");
6856 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6857 this->modePanZoomOption->getRootWidget(), "ArmAndActivate");
6858 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6859 this->modeRoamOption->getRootWidget(), "ArmAndActivate");
6860 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6861 this->modeRotateOption->getRootWidget(), "ArmAndActivate");
6862 TransferAccelerator(this->saveImageDialog->getRootWidget(),
6863 this->modeZoomOption->getRootWidget(), "ArmAndActivate");
6864
6865 return TRUE;
6866 }
6867
postPrintImageDialog()6868 boolean ImageWindow::postPrintImageDialog()
6869 {
6870 if(NOT this->printImageDialog)
6871 this->printImageDialog = new PrintImageDialog
6872 (this->getRootWidget(), (ImageNode*)this->node, this->commandScope);
6873
6874 this->printImageDialog->post();
6875 // Force Image's Translations onto PrintImageDialog here.
6876 TransferAccelerator(this->printImageDialog->getRootWidget(),
6877 this->saveOption->getRootWidget(), "ArmAndActivate");
6878 TransferAccelerator(this->printImageDialog->getRootWidget(),
6879 this->saveImageOption->getRootWidget(), "ArmAndActivate");
6880 TransferAccelerator(this->printImageDialog->getRootWidget(),
6881 this->printImageOption->getRootWidget(), "ArmAndActivate");
6882 TransferAccelerator(this->printImageDialog->getRootWidget(),
6883 this->closeOption->getRootWidget(), "ArmAndActivate");
6884 if(this->openAllControlPanelsOption)
6885 TransferAccelerator(this->printImageDialog->getRootWidget(),
6886 this->openAllControlPanelsOption->getRootWidget(), "ArmAndActivate");
6887 TransferAccelerator(this->printImageDialog->getRootWidget(),
6888 this->openAllColormapEditorsOption->getRootWidget(), "ArmAndActivate");
6889 TransferAccelerator(this->printImageDialog->getRootWidget(),
6890 this->messageWindowOption->getRootWidget(), "ArmAndActivate");
6891 TransferAccelerator(this->printImageDialog->getRootWidget(),
6892 this->undoOption->getRootWidget(), "ArmAndActivate");
6893 TransferAccelerator(this->printImageDialog->getRootWidget(),
6894 this->redoOption->getRootWidget(), "ArmAndActivate");
6895 TransferAccelerator(this->printImageDialog->getRootWidget(),
6896 this->resetOption->getRootWidget(), "ArmAndActivate");
6897 TransferAccelerator(this->printImageDialog->getRootWidget(),
6898 this->executeOnceOption->getRootWidget(), "ArmAndActivate");
6899 TransferAccelerator(this->printImageDialog->getRootWidget(),
6900 this->executeOnChangeOption->getRootWidget(), "ArmAndActivate");
6901 TransferAccelerator(this->printImageDialog->getRootWidget(),
6902 this->endExecutionOption->getRootWidget(), "ArmAndActivate");
6903
6904 TransferAccelerator(this->printImageDialog->getRootWidget(),
6905 this->modeCameraOption->getRootWidget(), "ArmAndActivate");
6906 TransferAccelerator(this->printImageDialog->getRootWidget(),
6907 this->modeCursorsOption->getRootWidget(), "ArmAndActivate");
6908 TransferAccelerator(this->printImageDialog->getRootWidget(),
6909 this->modePickOption->getRootWidget(), "ArmAndActivate");
6910 TransferAccelerator(this->printImageDialog->getRootWidget(),
6911 this->modeNavigateOption->getRootWidget(), "ArmAndActivate");
6912 TransferAccelerator(this->printImageDialog->getRootWidget(),
6913 this->modePanZoomOption->getRootWidget(), "ArmAndActivate");
6914 TransferAccelerator(this->printImageDialog->getRootWidget(),
6915 this->modeRoamOption->getRootWidget(), "ArmAndActivate");
6916 TransferAccelerator(this->printImageDialog->getRootWidget(),
6917 this->modeRotateOption->getRootWidget(), "ArmAndActivate");
6918 TransferAccelerator(this->printImageDialog->getRootWidget(),
6919 this->modeZoomOption->getRootWidget(), "ArmAndActivate");
6920
6921 return TRUE;
6922 }
6923
6924
6925 //
6926 // Before calling the super class method we verify that doing this will
6927 // leave at least one startup image window. If not, issue an error and
6928 // return without calling the super class method.
6929 //
toggleWindowStartup()6930 void ImageWindow::toggleWindowStartup()
6931 {
6932 List *images = this->network->getImageList();
6933 int doit = FALSE;
6934 ImageWindow *iw;
6935 ListIterator iterator(*images);
6936
6937 while ( (iw = (ImageWindow*)iterator.getNext()) ) {
6938 if ((iw != this) && iw->isStartup()) {
6939 doit = TRUE;
6940 break;
6941 }
6942 }
6943
6944 if (doit)
6945 this->DXWindow::toggleWindowStartup();
6946 else
6947 ErrorMessage("You must have at least one start up image window");
6948
6949 }
6950 //
6951 // Set the state and sensitivity of the ImageDepth cascade menu and its
6952 // command interfaces.
6953 //
configureImageDepthMenu()6954 void ImageWindow::configureImageDepthMenu()
6955 {
6956 if (this->imageDepthCascade) {
6957 ASSERT(this->imageDepth8Option);
6958 ASSERT(this->imageDepth12Option);
6959 ASSERT(this->imageDepth15Option);
6960 ASSERT(this->imageDepth16Option);
6961 ASSERT(this->imageDepth24Option);
6962 ASSERT(this->imageDepth32Option);
6963
6964 if (!this->node) {
6965 this->imageDepthCascade->deactivate();
6966 this->imageDepth8Cmd->deactivate();
6967 this->imageDepth12Cmd->deactivate();
6968 this->imageDepth15Cmd->deactivate();
6969 this->imageDepth16Cmd->deactivate();
6970 this->imageDepth24Cmd->deactivate();
6971 this->imageDepth32Cmd->deactivate();
6972 } else {
6973 boolean sw;
6974 this->getSoftware(sw);
6975 if (sw) {
6976 this->imageDepthCascade->activate();
6977 } else {
6978 this->imageDepthCascade->deactivate();
6979 }
6980
6981 Boolean sup8, sup12, sup15, sup16, sup24, sup32, frame_buffer;
6982 int canvas_depth;
6983 XtVaGetValues(this->getCanvas(),
6984 XmNdepth, &canvas_depth,
6985 XmNframeBuffer, &frame_buffer,
6986 XmN8supported, &sup8,
6987 XmN12supported, ¹2,
6988 XmN15supported, ¹5,
6989 XmN16supported, ¹6,
6990 XmN24supported, ²4,
6991 XmN32supported, ³2,
6992 NULL);
6993
6994 if (frame_buffer || !sw) {
6995 //
6996 // Set depth to 24 so the menu options look correct.
6997 //
6998 if (frame_buffer)
6999 canvas_depth = 24;
7000 this->imageDepth8Cmd->deactivate();
7001 this->imageDepth12Cmd->deactivate();
7002 this->imageDepth15Cmd->deactivate();
7003 this->imageDepth16Cmd->deactivate();
7004 this->imageDepth24Cmd->deactivate();
7005 this->imageDepth32Cmd->deactivate();
7006 } else {
7007 if (sup8 && canvas_depth != 8)
7008 this->imageDepth8Cmd->activate();
7009 else
7010 this->imageDepth8Cmd->deactivate();
7011 if (sup12 && canvas_depth != 12)
7012 this->imageDepth12Cmd->activate();
7013 if (sup15 && canvas_depth != 15)
7014 this->imageDepth15Cmd->activate();
7015 else
7016 this->imageDepth15Cmd->deactivate();
7017 if (sup16 && canvas_depth != 16)
7018 this->imageDepth16Cmd->activate();
7019 else
7020 this->imageDepth16Cmd->deactivate();
7021 if (sup24 && canvas_depth != 24)
7022 this->imageDepth24Cmd->activate();
7023 else
7024 this->imageDepth24Cmd->deactivate();
7025 if (sup32 && canvas_depth != 32)
7026 this->imageDepth32Cmd->activate();
7027 else
7028 this->imageDepth32Cmd->deactivate();
7029 }
7030
7031 this->imageDepth8Option->setState(canvas_depth == 8);
7032 this->imageDepth12Option->setState(canvas_depth == 12);
7033 this->imageDepth15Option->setState(canvas_depth == 15);
7034 this->imageDepth16Option->setState(canvas_depth == 16);
7035 this->imageDepth24Option->setState(canvas_depth == 24);
7036 this->imageDepth32Option->setState(canvas_depth == 32);
7037 }
7038 }
7039 }
7040
configureModeMenu()7041 void ImageWindow::configureModeMenu()
7042 {
7043 this->modeNoneOption->setState(this->getInteractionMode() == NONE);
7044 this->modeCameraOption->setState(this->getInteractionMode() == CAMERA);
7045 this->modeCursorsOption->setState(this->getInteractionMode() == CURSORS);
7046 this->modePickOption->setState(this->getInteractionMode() == PICK);
7047 this->modeNavigateOption->setState(this->getInteractionMode() == NAVIGATE);
7048 this->modePanZoomOption->setState(this->getInteractionMode() == PANZOOM);
7049 this->modeRoamOption->setState(this->getInteractionMode() == ROAM);
7050 this->modeRotateOption->setState(this->getInteractionMode() == ROTATE);
7051 this->modeZoomOption->setState(this->getInteractionMode() == ZOOM);
7052
7053 this->modeOptionCascade->setActivationFromChildren();
7054 }
7055
getNetwork()7056 Network *ImageWindow::getNetwork()
7057 {
7058 return this->network;
7059 }
7060 //
7061 // Update any displayed information from the new cfg state found in
7062 // the associated ImageNode.
7063 //
updateFromNewCfgState()7064 void ImageWindow::updateFromNewCfgState()
7065 {
7066 Dialog *d;
7067
7068 //
7069 // Ask the dialogs that display cfg information to update themselves
7070 // if they are managed.
7071 //
7072 d = this->viewControlDialog;
7073 if (d && d->isManaged()) d->manage();
7074 d = this->renderingOptionsDialog;
7075 if (d && d->isManaged()) d->manage();
7076 d = this->backgroundColorDialog;
7077 if (d && d->isManaged()) d->manage();
7078 d = this->throttleDialog;
7079 if (d && d->isManaged()) d->manage();
7080 d = this->autoAxesDialog;
7081 if (d && d->isManaged()) d->manage();
7082
7083
7084 }
7085
setAutoAxesDialogTicks()7086 void ImageWindow::setAutoAxesDialogTicks()
7087 {
7088 if (this->autoAxesDialog)
7089 this->autoAxesDialog->setAutoAxesDialogTicks();
7090 }
7091
setAutoAxesDialogXTickLocs()7092 void ImageWindow::setAutoAxesDialogXTickLocs()
7093 {
7094 if (this->autoAxesDialog)
7095 this->autoAxesDialog->setAutoAxesDialogXTickLocs();
7096 }
7097
setAutoAxesDialogYTickLocs()7098 void ImageWindow::setAutoAxesDialogYTickLocs()
7099 {
7100 if (this->autoAxesDialog)
7101 this->autoAxesDialog->setAutoAxesDialogYTickLocs();
7102 }
7103
setAutoAxesDialogZTickLocs()7104 void ImageWindow::setAutoAxesDialogZTickLocs()
7105 {
7106 if (this->autoAxesDialog)
7107 this->autoAxesDialog->setAutoAxesDialogZTickLocs();
7108 }
7109
setAutoAxesDialogXTickLabels()7110 void ImageWindow::setAutoAxesDialogXTickLabels()
7111 {
7112 if (this->autoAxesDialog)
7113 this->autoAxesDialog->setAutoAxesDialogXTickLabels();
7114 }
7115
setAutoAxesDialogYTickLabels()7116 void ImageWindow::setAutoAxesDialogYTickLabels()
7117 {
7118 if (this->autoAxesDialog)
7119 this->autoAxesDialog->setAutoAxesDialogYTickLabels();
7120 }
7121
setAutoAxesDialogZTickLabels()7122 void ImageWindow::setAutoAxesDialogZTickLabels()
7123 {
7124 if (this->autoAxesDialog)
7125 this->autoAxesDialog->setAutoAxesDialogZTickLabels();
7126 }
7127
setAutoAxesDialogFrame()7128 void ImageWindow::setAutoAxesDialogFrame()
7129 {
7130 if (this->autoAxesDialog)
7131 this->autoAxesDialog->setAutoAxesDialogFrame();
7132 }
7133
setAutoAxesDialogGrid()7134 void ImageWindow::setAutoAxesDialogGrid()
7135 {
7136 if (this->autoAxesDialog)
7137 this->autoAxesDialog->setAutoAxesDialogGrid();
7138 }
7139
setAutoAxesDialogAdjust()7140 void ImageWindow::setAutoAxesDialogAdjust()
7141 {
7142 if (this->autoAxesDialog)
7143 this->autoAxesDialog->setAutoAxesDialogAdjust();
7144 }
7145
setAutoAxesDialogLabels()7146 void ImageWindow::setAutoAxesDialogLabels()
7147 {
7148 if (this->autoAxesDialog)
7149 this->autoAxesDialog->setAutoAxesDialogLabels();
7150 }
7151
setAutoAxesDialogLabelScale()7152 void ImageWindow::setAutoAxesDialogLabelScale()
7153 {
7154 if (this->autoAxesDialog)
7155 this->autoAxesDialog->setAutoAxesDialogLabelScale();
7156 }
7157
setAutoAxesDialogFont()7158 void ImageWindow::setAutoAxesDialogFont()
7159 {
7160 if (this->autoAxesDialog)
7161 this->autoAxesDialog->setAutoAxesDialogFont();
7162 }
7163
setAutoAxesDialogAnnotationColors()7164 void ImageWindow::setAutoAxesDialogAnnotationColors()
7165 {
7166 if (this->autoAxesDialog)
7167 this->autoAxesDialog->setAutoAxesDialogAnnotationColors();
7168 }
7169
setAutoAxesDialogCorners()7170 void ImageWindow::setAutoAxesDialogCorners()
7171 {
7172 if (this->autoAxesDialog)
7173 this->autoAxesDialog->setAutoAxesDialogCorners();
7174 }
7175
setAutoAxesDialogCursor()7176 void ImageWindow::setAutoAxesDialogCursor()
7177 {
7178 if (this->autoAxesDialog)
7179 this->autoAxesDialog->setAutoAxesDialogCursor();
7180 }
7181
setAutoAxesDialogEnable()7182 void ImageWindow::setAutoAxesDialogEnable()
7183 {
7184 if (this->autoAxesDialog)
7185 this->autoAxesDialog->setAutoAxesDialogEnable();
7186 }
7187
isBGColorConnected()7188 boolean ImageWindow::isBGColorConnected()
7189 {
7190 if (!this->node->isA(ClassImageNode))
7191 return False;
7192 return ((ImageNode*)this->node)->isBGColorConnected();
7193 }
7194
isThrottleConnected()7195 boolean ImageWindow::isThrottleConnected()
7196 {
7197 if (!this->node->isA(ClassImageNode))
7198 return False;
7199 return ((ImageNode*)this->node)->isThrottleConnected();
7200 }
7201
isRecordEnableConnected()7202 boolean ImageWindow::isRecordEnableConnected()
7203 {
7204 if (!this->node->isA(ClassImageNode))
7205 return False;
7206 return ((ImageNode*)this->node)->isRecordEnableConnected();
7207 }
7208
isRecordFileConnected()7209 boolean ImageWindow::isRecordFileConnected()
7210 {
7211 if (!this->node->isA(ClassImageNode))
7212 return False;
7213 return ((ImageNode*)this->node)->isRecordFileConnected();
7214 }
7215
isRecordFormatConnected()7216 boolean ImageWindow::isRecordFormatConnected()
7217 {
7218 if (!this->node->isA(ClassImageNode))
7219 return False;
7220 return ((ImageNode*)this->node)->isRecordFormatConnected();
7221 }
7222
isRecordResolutionConnected()7223 boolean ImageWindow::isRecordResolutionConnected()
7224 {
7225 if (!this->node->isA(ClassImageNode))
7226 return False;
7227 return ((ImageNode*)this->node)->isRecordResolutionConnected();
7228 }
7229
isRecordAspectConnected()7230 boolean ImageWindow::isRecordAspectConnected()
7231 {
7232 if (!this->node->isA(ClassImageNode))
7233 return False;
7234 return ((ImageNode*)this->node)->isRecordAspectConnected();
7235 }
7236
isAutoAxesEnableConnected()7237 boolean ImageWindow::isAutoAxesEnableConnected()
7238 {
7239 if (!this->node->isA(ClassImageNode))
7240 return False;
7241 return ((ImageNode*)this->node)->isAutoAxesEnableConnected();
7242 }
7243
isAutoAxesCornersConnected()7244 boolean ImageWindow::isAutoAxesCornersConnected()
7245 {
7246 if (!this->node->isA(ClassImageNode))
7247 return False;
7248 return ((ImageNode*)this->node)->isAutoAxesCornersConnected();
7249 }
7250
isAutoAxesCursorConnected()7251 boolean ImageWindow::isAutoAxesCursorConnected()
7252 {
7253 if (!this->node->isA(ClassImageNode))
7254 return False;
7255 return ((ImageNode*)this->node)->isAutoAxesCursorConnected();
7256 }
7257
isAutoAxesFrameConnected()7258 boolean ImageWindow::isAutoAxesFrameConnected()
7259 {
7260 if (!this->node->isA(ClassImageNode))
7261 return False;
7262 return ((ImageNode*)this->node)->isAutoAxesFrameConnected();
7263 }
7264
isAutoAxesGridConnected()7265 boolean ImageWindow::isAutoAxesGridConnected()
7266 {
7267 if (!this->node->isA(ClassImageNode))
7268 return False;
7269 return ((ImageNode*)this->node)->isAutoAxesGridConnected();
7270 }
7271
isAutoAxesAdjustConnected()7272 boolean ImageWindow::isAutoAxesAdjustConnected()
7273 {
7274 if (!this->node->isA(ClassImageNode))
7275 return False;
7276 return ((ImageNode*)this->node)->isAutoAxesAdjustConnected();
7277 }
7278
isAutoAxesAnnotationConnected()7279 boolean ImageWindow::isAutoAxesAnnotationConnected()
7280 {
7281 if (!this->node->isA(ClassImageNode))
7282 return False;
7283 return ((ImageNode*)this->node)->isAutoAxesAnnotationConnected();
7284 }
7285
isAutoAxesLabelsConnected()7286 boolean ImageWindow::isAutoAxesLabelsConnected()
7287 {
7288 if (!this->node->isA(ClassImageNode))
7289 return False;
7290 return ((ImageNode*)this->node)->isAutoAxesLabelsConnected();
7291 }
7292
isAutoAxesColorsConnected()7293 boolean ImageWindow::isAutoAxesColorsConnected()
7294 {
7295 if (!this->node->isA(ClassImageNode))
7296 return False;
7297 return ((ImageNode*)this->node)->isAutoAxesColorsConnected();
7298 }
7299
isAutoAxesFontConnected()7300 boolean ImageWindow::isAutoAxesFontConnected()
7301 {
7302 if (!this->node->isA(ClassImageNode))
7303 return False;
7304 return ((ImageNode*)this->node)->isAutoAxesFontConnected();
7305 }
7306
isAutoAxesTicksConnected()7307 boolean ImageWindow::isAutoAxesTicksConnected()
7308 {
7309 if (!this->node->isA(ClassImageNode))
7310 return False;
7311 return ((ImageNode*)this->node)->isAutoAxesTicksConnected();
7312 }
7313
isAutoAxesXTickLocsConnected()7314 boolean ImageWindow::isAutoAxesXTickLocsConnected()
7315 {
7316 if (!this->node->isA(ClassImageNode))
7317 return False;
7318 return ((ImageNode*)this->node)->isAutoAxesXTickLocsConnected();
7319 }
7320
isAutoAxesYTickLocsConnected()7321 boolean ImageWindow::isAutoAxesYTickLocsConnected()
7322 {
7323 if (!this->node->isA(ClassImageNode))
7324 return False;
7325 return ((ImageNode*)this->node)->isAutoAxesYTickLocsConnected();
7326 }
7327
isAutoAxesZTickLocsConnected()7328 boolean ImageWindow::isAutoAxesZTickLocsConnected()
7329 {
7330 if (!this->node->isA(ClassImageNode))
7331 return False;
7332 return ((ImageNode*)this->node)->isAutoAxesZTickLocsConnected();
7333 }
7334
isAutoAxesXTickLabelsConnected()7335 boolean ImageWindow::isAutoAxesXTickLabelsConnected()
7336 {
7337 if (!this->node->isA(ClassImageNode))
7338 return False;
7339 return ((ImageNode*)this->node)->isAutoAxesXTickLabelsConnected();
7340 }
7341
isAutoAxesYTickLabelsConnected()7342 boolean ImageWindow::isAutoAxesYTickLabelsConnected()
7343 {
7344 if (!this->node->isA(ClassImageNode))
7345 return False;
7346 return ((ImageNode*)this->node)->isAutoAxesYTickLabelsConnected();
7347 }
7348
isAutoAxesZTickLabelsConnected()7349 boolean ImageWindow::isAutoAxesZTickLabelsConnected()
7350 {
7351 if (!this->node->isA(ClassImageNode))
7352 return False;
7353 return ((ImageNode*)this->node)->isAutoAxesZTickLabelsConnected();
7354 }
7355
isAutoAxesLabelScaleConnected()7356 boolean ImageWindow::isAutoAxesLabelScaleConnected()
7357 {
7358 if (!this->node->isA(ClassImageNode))
7359 return False;
7360 return ((ImageNode*)this->node)->isAutoAxesLabelScaleConnected();
7361 }
7362
isRenderModeConnected()7363 boolean ImageWindow::isRenderModeConnected()
7364 {
7365 if (!this->node->isA(ClassImageNode))
7366 return False;
7367 return ((ImageNode*)this->node)->isRenderModeConnected();
7368 }
7369
isButtonUpApproxConnected()7370 boolean ImageWindow::isButtonUpApproxConnected()
7371 {
7372 if (!this->node->isA(ClassImageNode))
7373 return False;
7374 return ((ImageNode*)this->node)->isButtonUpApproxConnected();
7375 }
7376
isButtonDownApproxConnected()7377 boolean ImageWindow::isButtonDownApproxConnected()
7378 {
7379 if (!this->node->isA(ClassImageNode))
7380 return False;
7381 return ((ImageNode*)this->node)->isButtonDownApproxConnected();
7382 }
7383
isButtonUpDensityConnected()7384 boolean ImageWindow::isButtonUpDensityConnected()
7385 {
7386 if (!this->node->isA(ClassImageNode))
7387 return False;
7388 return ((ImageNode*)this->node)->isButtonUpDensityConnected();
7389 }
7390
isButtonDownDensityConnected()7391 boolean ImageWindow::isButtonDownDensityConnected()
7392 {
7393 if (!this->node->isA(ClassImageNode))
7394 return False;
7395 return ((ImageNode*)this->node)->isButtonDownDensityConnected();
7396 }
7397
sensitizePrintImageDialog(boolean flag)7398 void ImageWindow::sensitizePrintImageDialog(boolean flag)
7399 {
7400 if (this->printImageCmd)
7401 this->printImageCmd->activate();
7402
7403 if (this->printImageDialog)
7404 this->printImageDialog->setCommandActivation();
7405 }
7406
sensitizeSaveImageDialog(boolean flag)7407 void ImageWindow::sensitizeSaveImageDialog(boolean flag)
7408 {
7409 if (this->saveImageCmd)
7410 this->saveImageCmd->activate();
7411
7412 if (this->saveImageDialog)
7413 this->saveImageDialog->setCommandActivation();
7414 }
7415
sensitizeThrottleDialog(boolean flag)7416 void ImageWindow::sensitizeThrottleDialog(boolean flag)
7417 {
7418 if (flag == False)
7419 {
7420 if (this->throttleCmd)
7421 this->throttleCmd->deactivate();
7422 if (this->throttleDialog && this->throttleDialog->isManaged())
7423 this->throttleDialog->unmanage();
7424 }
7425 else
7426 {
7427 if (this->throttleCmd)
7428 this->throttleCmd->activate();
7429 double v;
7430 this->getThrottle(v);
7431 this->updateThrottleDialog(v);
7432 }
7433 }
7434
sensitizeBackgroundColorDialog(boolean flag)7435 void ImageWindow::sensitizeBackgroundColorDialog(boolean flag)
7436 {
7437 if (flag == False)
7438 {
7439 if (this->backgroundColorCmd)
7440 this->backgroundColorCmd->deactivate();
7441 if (this->backgroundColorDialog &&
7442 this->backgroundColorDialog->isManaged())
7443 this->backgroundColorDialog->unmanage();
7444 }
7445 else
7446 {
7447 if (this->backgroundColorCmd)
7448 this->backgroundColorCmd->activate();
7449 this->updateBGColorDialog(NULL);
7450 }
7451 }
7452
7453
7454
updateAutoAxesDialog()7455 void ImageWindow::updateAutoAxesDialog()
7456 {
7457 if (this->autoAxesDialog)
7458 this->autoAxesDialog->update();
7459 }
7460
sensitizeViewControl(boolean flag)7461 void ImageWindow::sensitizeViewControl(boolean flag)
7462 {
7463 if (flag)
7464 {
7465 List *l = this->network->makeClassifiedNodeList(ClassProbeNode, FALSE);
7466 if (l) {
7467 delete l;
7468 this->modeCursorsCmd->activate();
7469 }
7470
7471 l = this->network->makeClassifiedNodeList(ClassPickNode);
7472 if (l) {
7473 delete l;
7474 this->modePickCmd->activate();
7475 }
7476 this->modeNoneCmd->activate();
7477 this->modeCameraCmd->activate();
7478 this->modeNavigateCmd->activate();
7479 this->modePanZoomCmd->activate();
7480 this->modeRoamCmd->activate();
7481 this->modeRotateCmd->activate();
7482 this->modeZoomCmd->activate();
7483 if (this->viewControlDialog)
7484 {
7485 this->viewControlDialog->sensitizeProbeOptionMenu(TRUE);
7486 this->viewControlDialog->sensitizePickOptionMenu(TRUE);
7487 }
7488 }
7489 else
7490 {
7491 this->modeNoneCmd->deactivate();
7492 this->modeCameraCmd->deactivate();
7493 this->modeNavigateCmd->deactivate();
7494 this->modePanZoomCmd->deactivate();
7495 this->modeRoamCmd->deactivate();
7496 this->modeRotateCmd->deactivate();
7497 this->modeZoomCmd->deactivate();
7498 this->modeCursorsCmd->deactivate();
7499 this->modePickCmd->deactivate();
7500 if (this->viewControlDialog)
7501 {
7502 this->viewControlDialog->resetMode();
7503 this->viewControlDialog->sensitizeProbeOptionMenu(FALSE);
7504 this->viewControlDialog->sensitizePickOptionMenu(FALSE);
7505 }
7506 }
7507 this->configureModeMenu();
7508 }
7509
sensitizeChangeImageName(boolean flag)7510 void ImageWindow::sensitizeChangeImageName(boolean flag)
7511 {
7512 if (flag)
7513 {
7514 if (this->changeImageNameCmd)
7515 this->changeImageNameCmd->activate();
7516 if ((this->changeImageNameDialog) && (this->changeImageNameDialog->isManaged()))
7517 this->changeImageNameDialog->installEditorText();
7518 }
7519 else
7520 {
7521 if (this->changeImageNameCmd)
7522 this->changeImageNameCmd->deactivate();
7523 if (this->changeImageNameDialog)
7524 this->changeImageNameDialog->unmanage();
7525 }
7526 }
7527
sensitizeRenderMode(boolean flag)7528 void ImageWindow::sensitizeRenderMode(boolean flag)
7529 {
7530 if (this->renderingOptionsDialog)
7531 this->renderingOptionsDialog->sensitizeRenderMode(flag);
7532 }
7533
sensitizeButtonUpApprox(boolean flag)7534 void ImageWindow::sensitizeButtonUpApprox(boolean flag)
7535 {
7536 if (this->renderingOptionsDialog)
7537 this->renderingOptionsDialog->sensitizeButtonUpApprox(flag);
7538 }
7539
sensitizeButtonDownApprox(boolean flag)7540 void ImageWindow::sensitizeButtonDownApprox(boolean flag)
7541 {
7542 if (this->renderingOptionsDialog)
7543 this->renderingOptionsDialog->sensitizeButtonDownApprox(flag);
7544 }
7545
sensitizeButtonUpDensity(boolean flag)7546 void ImageWindow::sensitizeButtonUpDensity(boolean flag)
7547 {
7548 if (this->renderingOptionsDialog)
7549 this->renderingOptionsDialog->sensitizeButtonUpDensity(flag);
7550 }
7551
sensitizeButtonDownDensity(boolean flag)7552 void ImageWindow::sensitizeButtonDownDensity(boolean flag)
7553 {
7554 if (this->renderingOptionsDialog)
7555 this->renderingOptionsDialog->sensitizeButtonDownDensity(flag);
7556 }
7557
updateRenderingOptionsDialog()7558 void ImageWindow::updateRenderingOptionsDialog()
7559 {
7560 if (this->renderingOptionsDialog)
7561 this->renderingOptionsDialog->update();
7562 }
7563
7564
7565 //
7566 // If the X window id of the canvas changed then set the WHERE parameter
7567 // dirty. As of Aug,95 MainWindow::setGeometry was implemented using
7568 // unrealize/realize.
7569 //
setGeometry(int x,int y,int width,int height)7570 void ImageWindow::setGeometry(int x, int y, int width, int height)
7571 {
7572 //
7573 // The comments, if they exist may cause a resize, but we don't
7574 // want to cause an execution that normally results from a resize
7575 // if we're currently reading a network. So we'll "push" them.
7576 // When we're finished reading the network, we'll go back and "pop"
7577 // them and apply the settings. Important result: when you're
7578 // reading both .net and .cfg the image window won't move, then
7579 // go away and reappear in the same spot - a result of applying
7580 // window placment info twice.
7581 //
7582 boolean resettable_eoc_mode = FALSE;
7583 if ((this->isExecuteOnResize()) && (this->network->isReadingNetwork()))
7584 resettable_eoc_mode = TRUE;
7585 if (resettable_eoc_mode)
7586 this->setExecuteOnResize(FALSE);
7587
7588 DisplayNode* dn = (DisplayNode*)this->node;
7589 if (dn) {
7590 ASSERT(this->node->isA(ClassDisplayNode));
7591 }
7592 Widget canvas = this->getCanvas();
7593 Window oldWindow = XtWindow(canvas);
7594 if ((this->hasPendingWindowPlacement()) || (resettable_eoc_mode)) {
7595 this->pending_resize_x = x;
7596 this->pending_resize_y = y;
7597 this->pending_resize_width = width;
7598 this->pending_resize_height = height;
7599 if (dn) dn->notifyWhereChange(FALSE);
7600 } else {
7601 //
7602 // The way it's supposed to work: If you call setGeometry, then
7603 // ImageWindow::resizeImage will be called also - as the window
7604 // resizes. But if the args to setGeometry are equal to current
7605 // dimensions then resizeImage won't be called. That's bad because
7606 // it means that loading a new cfg file which contains Camera(resolution)
7607 // and window dims which disagree will result in the Camera(resolution)
7608 // param giving us a new size after execution. Problem is we don't know
7609 // what resolution and aspect should be. We rely on Motif to tell
7610 // us that.
7611 //
7612 // Normal behavior inside a Picture widget includes setting its
7613 // own XmNpicturePixmap to XmUNSPECIFIED_PIXMAP whenever the widget
7614 // changes size. We're doing that for Picture in this case because
7615 // when we set new size and new size == old size, the widget's Resize
7616 // method is not called. Note that MainWindow::setGeometry could
7617 // possible do the Unrealize/Realize thing even the new dimensions
7618 // are equal to the old. (It should also work to unset XmNpicturePixmap
7619 // inside the Realize method of Picture widget.)
7620 //
7621 this->DXWindow::setGeometry(x, y, width, height);
7622 XSync (XtDisplay(theApplication->getRootWidget()), False);
7623 this->resizeImage(FALSE);
7624 }
7625
7626 Window newWindow = XtWindow(canvas);
7627
7628 if ((oldWindow != newWindow) && (dn)) {
7629 dn->notifyWhereChange(FALSE);
7630 this->allowDirectInteraction(FALSE);
7631 }
7632
7633 if (resettable_eoc_mode)
7634 this->resetExecuteOnResizeWhenAble();
7635 }
7636
7637 //
7638 // Called by the MainWindow CloseCallback. We call the super class
7639 // method and then, if we are not an anchor and are in DataViewer mode
7640 // then we exit the program.
7641 //
closeWindow()7642 void ImageWindow::closeWindow()
7643 {
7644 this->DXWindow::closeWindow();
7645 if (!this->anchor && theDXApplication->inDataViewerMode())
7646 theDXApplication->shutdownApplication();
7647 }
7648
postWizard()7649 void ImageWindow::postWizard()
7650 {
7651 if (theDXApplication->inWizardMode() == FALSE) return;
7652
7653 boolean keep_trying = TRUE;
7654 if (theDXApplication->isWizardWindow(this->UIComponent::name)) {
7655 Command *cmd = this->network->getHelpOnNetworkCommand();
7656 if (cmd->isActive()) {
7657 cmd->execute();
7658 keep_trying = FALSE;
7659 }
7660 }
7661
7662 if (keep_trying)
7663 this->DXWindow::postWizard();
7664 }
7665
7666 //
7667 // Use a workproc to turn execute-on-resize back on. This is done on behalf
7668 // of DisplayNode::parseCommonComments() which is triggering an execution.
7669 // It calls setGeometry(), setExecuteOnResize(TRUE) in an attempt to prevent an
7670 // execution following parsing/setting geometry, but it doesn't work, because
7671 // the resize happens async.
7672 //
resetExecuteOnResizeWhenAble()7673 void ImageWindow::resetExecuteOnResizeWhenAble()
7674 {
7675 if (this->reset_eor_wp)
7676 XtRemoveWorkProc (this->reset_eor_wp);
7677 XtAppContext apcxt = theApplication->getApplicationContext();
7678 this->reset_eor_wp = XtAppAddWorkProc (apcxt, (XtWorkProc)
7679 ImageWindow_ResetEORWP, (XtPointer)this);
7680 ImageWindow::NeedsSyncForResize = TRUE;
7681 }
7682
ImageWindow_ResetEORWP(XtPointer clientData)7683 extern "C" Boolean ImageWindow_ResetEORWP (XtPointer clientData)
7684 {
7685 ImageWindow* iw = (ImageWindow*)clientData;
7686 ASSERT(iw);
7687 if (ImageWindow::NeedsSyncForResize) {
7688 XSync (XtDisplay(iw->getRootWidget()), False);
7689 ImageWindow::NeedsSyncForResize = FALSE;
7690 return False;
7691 }
7692
7693 iw->reset_eor_wp = NUL(XtWorkProcId);
7694 iw->setGeometry( iw->pending_resize_x, iw->pending_resize_y,
7695 iw->pending_resize_width, iw->pending_resize_height);
7696 iw->setExecuteOnResize(TRUE);
7697 return TRUE;
7698 }
7699
7700
getGeometryAlternateNames(String * names,int * count,int max)7701 void ImageWindow::getGeometryAlternateNames(String* names, int* count, int max)
7702 {
7703 int cnt = *count;
7704
7705 if (cnt < (max-1)) {
7706 List* il = this->network->getImageList();
7707 int pos = il->getPosition((void*)this);
7708
7709 if (pos) {
7710 char* name = new char[32];
7711 sprintf (name, "%s%d", this->name,pos);
7712 names[cnt++] = name;
7713 *count = cnt;
7714 }
7715 }
7716 this->DXWindow::getGeometryAlternateNames(names, count, max);
7717 }
7718
setWindowTitle(const char * name,boolean check_geometry)7719 void ImageWindow::setWindowTitle(const char* name, boolean check_geometry)
7720 {
7721 DXPacketIF* p = theDXApplication->getPacketIF();
7722 //
7723 // We can't handle a where param change during an execution. The
7724 // new window placement code could cause one: connect a wire to
7725 // the image title parameter.
7726 //
7727 this->DXWindow::setWindowTitle(name, (check_geometry && (p==NUL(DXPacketIF*))));
7728 }
7729