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 
13 #ifndef _ImageWindow_h
14 #define _ImageWindow_h
15 
16 #include <X11/Intrinsic.h>
17 #include "DXWindow.h"
18 #include "NoUndoImageCommand.h"
19 #include "ToggleButtonInterface.h"
20 #include "../widgets/Picture.h"
21 #include "enums.h"
22 #include "Network.h"
23 //#include "AutoAxesDialog.h"
24 //#include "SetBGColorDialog.h"
25 
26 
27 //
28 // Class name definition:
29 //
30 #define ClassImageWindow	"ImageWindow"
31 
32 //
33 // XtCallbackProc (*CB), XtEventHandler (*EH) and XtActionProc (*AP)
34 // DialogCallback (*DCB), XtInputCallbackProc (*ICP), XtWorkProc (*WP)
35 // functions for this and derived classes
36 //
37 extern "C" void ImageWindow_ChangeImageNameCB(Widget, XtPointer, XtPointer);
38 extern "C" void ImageWindow_TrackFrameBufferEH(Widget, XtPointer, XEvent*, Boolean*);
39 extern "C" void ImageWindow_PropertyNotifyCB(Widget, XtPointer, XtPointer);
40 extern "C" void ImageWindow_ClientMessageCB(Widget, XtPointer, XtPointer);
41 extern "C" void ImageWindow_ResizeCB(Widget, XtPointer, XtPointer);
42 extern "C" void ImageWindow_UndoCB(Widget, XtPointer, XtPointer);
43 extern "C" void ImageWindow_KeyCB(Widget, XtPointer, XtPointer);
44 extern "C" void ImageWindow_ModeCB(Widget, XtPointer, XtPointer);
45 extern "C" void ImageWindow_PickCB(Widget, XtPointer, XtPointer);
46 extern "C" void ImageWindow_CursorCB(Widget, XtPointer, XtPointer);
47 extern "C" void ImageWindow_RotationCB(Widget, XtPointer, XtPointer);
48 extern "C" void ImageWindow_NavigateCB(Widget, XtPointer, XtPointer);
49 extern "C" void ImageWindow_RoamCB(Widget, XtPointer, XtPointer);
50 extern "C" void ImageWindow_ZoomCB(Widget, XtPointer, XtPointer);
51 extern "C" void ImageWindow_RedrawCB(Widget, XtPointer, XtPointer);
52 extern "C" void ImageWindow_WindowsMenuMapCB(Widget, XtPointer, XtPointer);
53 extern "C" void ImageWindow_FileMenuMapCB(Widget, XtPointer, XtPointer);
54 extern "C" Boolean ImageWindow_ResetEORWP(XtPointer);
55 extern "C" void ImageWindow_ResizeTO (XtPointer , XtIntervalId* );
56 
57 //
58 // Referenced classes:
59 //
60 /*
61 class Network;
62 */
63 class CommandScope;
64 class CommandInterface;
65 class Command;
66 class Node;
67 class ProbeNode;
68 class PickNode;
69 class ViewControlDialog;
70 class RenderingOptionsDialog;
71 class Dialog;
72 class AutoAxesDialog;
73 class XHandler;
74 class ThrottleDialog;
75 class PanelAccessManager;
76 class SaveImageDialog;
77 class SetImageNameDialog;
78 class PrintImageDialog;
79 class CascadeMenu;
80 class SetBGColorDialog;
81 class Stack;
82 
83 enum ApproxMode
84 {
85     APPROX_NONE,
86     APPROX_WIREFRAME,
87     APPROX_DOTS,
88     APPROX_BOX
89 };
90 
91 enum ViewDirection
92 {
93     VIEW_NONE,
94     VIEW_TOP,
95     VIEW_BOTTOM,
96     VIEW_FRONT,
97     VIEW_BACK,
98     VIEW_LEFT,
99     VIEW_RIGHT,
100     VIEW_DIAGONAL,
101     VIEW_OFF_TOP,
102     VIEW_OFF_BOTTOM,
103     VIEW_OFF_FRONT,
104     VIEW_OFF_BACK,
105     VIEW_OFF_LEFT,
106     VIEW_OFF_RIGHT,
107     VIEW_OFF_DIAGONAL
108 };
109 enum LookDirection
110 {
111     LOOK_FORWARD,
112     LOOK_LEFT45,
113     LOOK_RIGHT45,
114     LOOK_UP45,
115     LOOK_DOWN45,
116     LOOK_LEFT90,
117     LOOK_RIGHT90,
118     LOOK_UP90,
119     LOOK_DOWN90,
120     LOOK_BACKWARD,
121     LOOK_ALIGN
122 };
123 
124 enum ConstraintDirection
125 {
126     CONSTRAINT_NONE,
127     CONSTRAINT_X,
128     CONSTRAINT_Y,
129     CONSTRAINT_Z
130 };
131 
132 struct ImageAtoms
133 {
134     Atom                pick_point;        // Atoms for GL client  */
135     Atom                start_pick;        // Atoms for GL client  */
136     Atom                set_view;          // Atoms for GL client  */
137     Atom                start_rotate;      // Atoms for GL client  */
138     Atom                stop;              // Atoms for GL client  */
139     Atom                start_zoom;        // Atoms for GL client  */
140     Atom                start_panzoom;     // Atoms for GL client  */
141     Atom                start_cursor;      // Atoms for GL client  */
142     Atom                start_roam;        // Atoms for GL client  */
143     Atom                start_navigate;    // Atoms for GL client  */
144     Atom                from_vector;       // Atoms for GL client  */
145     Atom                up_vector;         // Atoms for GL client  */
146     Atom                zoom1;             // Atoms for GL client  */
147     Atom                zoom2;             // Atoms for GL client  */
148     Atom                roam;              // Atoms for GL client  */
149     Atom                cursor_change;     // Atoms for GL client  */
150     Atom                cursor_constraint; // Atoms for GL client  */
151     Atom                cursor_speed;      // Atoms for GL client  */
152     Atom                gl_window0;        // Atoms for GL server  */
153     Atom                gl_window1;        // Atoms for GL server  */
154     Atom                gl_window2;        // Atoms for GL server  */
155     Atom                gl_window2_execute;// Atoms for GL server  */
156     Atom                execute_on_change; // Atoms for GL server  */
157     Atom                gl_destroy_window; // Atoms for GL server  */
158     Atom                gl_shutdown;       // Atoms for GL server  */
159     Atom                image_reset;       // Atoms for DX server  */
160     Atom                dx_pixmap_id;      // Atoms for DX server  */
161     Atom                dx_flag;           // Atoms for DX server  */
162     Atom                display_globe;     // Atoms for DX server  */
163     Atom                motion;            // Atoms for DX server  */
164     Atom                pivot;             // Atoms for DX server  */
165     Atom                undoable;          // Atoms for DX server  */
166     Atom                redoable;          // Atoms for DX server  */
167     Atom                undo_camera;       // Atoms for DX server  */
168     Atom                redo_camera;       // Atoms for DX server  */
169     Atom                push_camera;       // Atoms for DX server  */
170     Atom                button_mapping1;   // Atoms for DX server  */
171     Atom                button_mapping2;   // Atoms for DX server  */
172     Atom                button_mapping3;   // Atoms for DX server  */
173     Atom                navigate_look_at;  // Atoms for DX server  */
174 };
175 struct ImageCamera {
176     double  to[3];
177     double  up[3];
178     double  from[3];
179     double  width;
180     int     windowWidth;
181     int     windowHeight;
182     double  viewAngle;
183     double  zoomFactor;
184     double  aspect;
185     int     projection;
186     boolean undoable;
187     boolean redoable;
188 };
189 struct ImageState {
190     int			width;
191     int			height;
192     Pixmap		pixmap;
193     GC			gc;
194     boolean		hardwareRender;
195     boolean		hardwareRenderExists;
196     boolean		resizeFromServer;
197     boolean		frameBuffer;
198     long		hardwareWindow;
199     ImageCamera		hardwareCamera;
200     boolean		globeDisplayed;
201     boolean		degenerateBox;
202     int			imageCount;
203     boolean		resizeCausesExecution;
204     //
205     // when turning resizeCausesExecution back on (it's turned off during
206     // parsing), set a flag which will cause it to be turned on after a resize
207     // event is delivered.  Otherwise the async arrival of a resize event will
208     // cause an execution.
209     //
210     struct {
211 	Window			window;
212 	int			x;
213 	int			y;
214 	int			width;
215 	int			height;
216     }			parent;
217     double 		navigateTranslateSpeed;
218     double 		navigateRotateSpeed;
219 };
220 
221 
222 //
223 // ImageWindow class definition:
224 //
225 class ImageWindow : public DXWindow
226 {
227     friend class NoUndoImageCommand;
228 
229   private:
230     //
231     // Private class data:
232     //
233     static boolean ClassInitialized;
234 
235     friend void ImageWindow_FileMenuMapCB(Widget, XtPointer, XtPointer);
236     friend void ImageWindow_WindowsMenuMapCB(Widget, XtPointer, XtPointer);
237 
238     //
239     // Static callback routines.
240     //
241     friend void ImageWindow_RedrawCB(Widget	 drawingArea,
242 		         XtPointer clientData,
243 		         XtPointer callData);
244     friend void ImageWindow_ZoomCB(Widget	 drawingArea,
245 		       XtPointer clientData,
246 		       XtPointer callData);
247     friend void ImageWindow_RoamCB(Widget	 drawingArea,
248 		       XtPointer clientData,
249 		       XtPointer callData);
250     friend void ImageWindow_NavigateCB(Widget	 drawingArea,
251 		           XtPointer clientData,
252 		           XtPointer callData);
253     friend void ImageWindow_RotationCB(Widget	 drawingArea,
254 		           XtPointer clientData,
255 		           XtPointer callData);
256     friend void ImageWindow_CursorCB(Widget	 drawingArea,
257 		         XtPointer clientData,
258 		         XtPointer callData);
259     friend void ImageWindow_PickCB(Widget	 drawingArea,
260 		       XtPointer clientData,
261 		       XtPointer callData);
262     friend void ImageWindow_ModeCB(Widget	 drawingArea,
263 		       XtPointer clientData,
264 		       XtPointer callData);
265     friend void ImageWindow_KeyCB(Widget	 drawingArea,
266 		      XtPointer clientData,
267 		      XtPointer callData);
268     friend void ImageWindow_UndoCB(Widget	 drawingArea,
269 		       XtPointer clientData,
270 		       XtPointer callData);
271     friend void ImageWindow_ResizeCB(Widget	 drawingArea,
272 		        XtPointer clientData,
273 		        XtPointer callData);
274     friend void ImageWindow_ClientMessageCB(Widget 	  drawingArea,
275 			        XtPointer clientData,
276 			        XtPointer callData);
277     friend void ImageWindow_PropertyNotifyCB(Widget   drawingArea,
278 				XtPointer clientData,
279 				XtPointer callData);
280     friend void ImageWindow_TrackFrameBufferEH(Widget    drawingArea,
281 				   XtPointer clientData,
282 				   XEvent    *callData,
283 				   Boolean   *continue_to_dispatch);
284     static boolean HandleExposures(XEvent *event, void *clientData);
285     friend void ImageWindow_ChangeImageNameCB(Widget    selectBox,
286 		      		  XtPointer clientData,
287 		      		  XtPointer callData);
288     friend Boolean ImageWindow_ResetEORWP(XtPointer);
289     friend void ImageWindow_ResizeTO (XtPointer , XtIntervalId* );
290     boolean adjustDepth(int &depth);
291 
292     void completePictureCreation();
293     List         panelNameList;
294     List         panelGroupList;
295 
296     //
297     // Ah yes, interaction modes.  I recently added the
298     // 'pendingInteractionMode' member, because it seems that under
299     // certain cirmumstances, setInteractionMode() was not actually
300     // installing the mode in the window.  In these cases, we save
301     // the new mode in pendingInteractionMode and set currentInteractionMode
302     // to NONE.  Then at a later time (when we get a canvas) we can
303     // apply the pending interaction mode with applyPendingInteractionMode().
304     //
305     // Install the given mode as the new interaction mode.
306     // If ignoreMatchingModes is FALSE, then we return immediately if the
307     // mode is already set otherwise, we go ahead and set the window for
308     // the given mode.  See, set/activateInteractionMode().
309     //
310     DirectInteractionMode pendingInteractionMode;
311     DirectInteractionMode currentInteractionMode;
312     boolean setInteractionMode(DirectInteractionMode mode,
313                         boolean ignoreMatchingModes);
314 #if 00
315     boolean activateInteractionMode();
316 #endif
317     boolean applyPendingInteractionMode();
318 
319     Network*		network;
320 
321     //
322     // Image state
323     //
324     boolean		directInteraction;
325     ImageAtoms		atoms;
326     ImageState		state;
327     Stack*		managed_state;
328 
329     // are we just switching between hardware and software?
330     boolean		switchingSoftware;
331 
332     // Have we pushed since the last execution?
333     boolean		pushedSinceExec;
334 
335     int		currentProbeInstance;
336     int		currentPickInstance;
337 
338     Node		*node;		// Display or Image node associated.
339 
340 
341     ViewControlDialog       *viewControlDialog;
342     RenderingOptionsDialog  *renderingOptionsDialog;
343     SetBGColorDialog        *backgroundColorDialog;
344     ThrottleDialog          *throttleDialog;
345     AutoAxesDialog          *autoAxesDialog;
346     SetImageNameDialog	    *changeImageNameDialog;
347     SaveImageDialog         *saveImageDialog;
348     PrintImageDialog        *printImageDialog;
349 
350     XHandler		    *fbEventHandler;
351 
352 
353 
354     virtual void resizeImage(boolean ok_to_send=TRUE);
355     virtual void zoomImage(XmPictureCallbackStruct*);
356     virtual void roamImage(XmPictureCallbackStruct*);
357     virtual void rotateImage(XmPictureCallbackStruct*);
358     virtual void navigateImage(XmPictureCallbackStruct*);
359     virtual void handleMode(XmPictureCallbackStruct*);
360     virtual void handleKey(XmPictureCallbackStruct*);
361     virtual void pickImage(double x, double y);
362     virtual void handleCursor(int reason, int cursor_num,
363 			      double x, double y, double z);
364 
365     //
366     // Image window commands:
367     //
368     Command		*renderingOptionsCmd;
369     Command			*softwareCmd;
370     Command			*hardwareCmd;
371     Command			*upNoneCmd;
372     Command			*upWireframeCmd;
373     Command			*upDotsCmd;
374     Command			*upBoxCmd;
375     Command			*downNoneCmd;
376     Command			*downWireframeCmd;
377     Command			*downDotsCmd;
378     Command			*downBoxCmd;
379     Command		*autoAxesCmd;
380     Command		*throttleCmd;
381     Command		*viewControlCmd;
382     Command			*modeNoneCmd;
383     Command			*modeCameraCmd;
384     Command			*modeCursorsCmd;
385     Command			*modePickCmd;
386     Command			*modeNavigateCmd;
387     Command			*modePanZoomCmd;
388     Command			*modeRoamCmd;
389     Command			*modeRotateCmd;
390     Command			*modeZoomCmd;
391     Command			*setViewNoneCmd;
392     Command			*setViewTopCmd;
393     Command			*setViewBottomCmd;
394     Command			*setViewFrontCmd;
395     Command			*setViewBackCmd;
396     Command			*setViewLeftCmd;
397     Command			*setViewRightCmd;
398     Command			*setViewDiagonalCmd;
399     Command			*setViewOffTopCmd;
400     Command			*setViewOffBottomCmd;
401     Command			*setViewOffFrontCmd;
402     Command			*setViewOffBackCmd;
403     Command			*setViewOffLeftCmd;
404     Command			*setViewOffRightCmd;
405     Command			*setViewOffDiagonalCmd;
406     Command			*perspectiveCmd;
407     Command			*parallelCmd;
408     Command			*constrainNoneCmd;
409     Command			*constrainXCmd;
410     Command			*constrainYCmd;
411     Command			*constrainZCmd;
412     Command			*lookForwardCmd;
413     Command			*lookLeft45Cmd;
414     Command			*lookRight45Cmd;
415     Command			*lookUp45Cmd;
416     Command			*lookDown45Cmd;
417     Command			*lookLeft90Cmd;
418     Command			*lookRight90Cmd;
419     Command			*lookUp90Cmd;
420     Command			*lookDown90Cmd;
421     Command			*lookBackwardCmd;
422     Command			*lookAlignCmd;
423     Command		*undoCmd;
424     Command		*redoCmd;
425     Command		*resetCmd;
426     Command		*changeImageNameCmd;
427     Command		*backgroundColorCmd;
428     Command		*displayRotationGlobeCmd;
429     Command             *openVPECmd;
430     CascadeMenu		*modeOptionCascade;
431     CascadeMenu		*imageDepthCascade;
432     Command             *imageDepth8Cmd;
433     Command             *imageDepth12Cmd;
434     Command             *imageDepth15Cmd;
435     Command             *imageDepth16Cmd;
436     Command             *imageDepth24Cmd;
437     Command		*imageDepth32Cmd;
438     Command		*closeCmd;
439     Command		*setPanelAccessCmd;
440     Command		*saveImageCmd;
441     Command		*printImageCmd;
442 
443     //
444     // Image window components:
445     //
446     Widget		form;
447     Widget		canvas;
448 
449     //
450     // Menus & pulldowns:
451     //
452     Widget		fileMenu;
453     Widget		windowsMenu;
454     Widget		optionsMenu;
455 
456     Widget		fileMenuPulldown;
457     Widget		editMenuPulldown;
458     Widget		windowsMenuPulldown;
459     Widget		optionsMenuPulldown;
460 
461     //
462     // File menu options:
463     //
464     CommandInterface*	openOption;
465     CommandInterface*	saveOption;
466     CommandInterface*	saveAsOption;
467     CommandInterface*	openCfgOption;
468     CommandInterface*	saveCfgOption;
469     CommandInterface*	loadMacroOption;
470     CommandInterface*	loadMDFOption;
471     CommandInterface*   quitOption;
472     CommandInterface*   closeOption;
473     CommandInterface*	saveImageOption;
474     CommandInterface*	printImageOption;
475     CascadeMenu*	cfgSettingsCascadeMenu;
476 
477     //
478     // Windows menu options:
479     //
480     CommandInterface*	openVisualProgramEditorOption;
481     CommandInterface*	openAllControlPanelsOption;
482     CascadeMenu		*openControlPanelByNameMenu;
483     CommandInterface*	openAllColormapEditorsOption;
484     CommandInterface*	messageWindowOption;
485 
486     //
487     // Options menu options:
488     //
489     CommandInterface*	renderingOptionsOption;
490     CommandInterface*	autoAxesOption;
491     CommandInterface*	throttleOption;
492     CommandInterface*	viewControlOption;
493     CommandInterface*	modeOption;
494     CommandInterface*	undoOption;
495     CommandInterface*	redoOption;
496     CommandInterface*	resetOption;
497     CommandInterface*	changeImageNameOption;
498     CommandInterface*	backgroundColorOption;
499     CommandInterface*	displayRotationGlobeOption;
500 
501     ToggleButtonInterface*	modeNoneOption;
502     ToggleButtonInterface*	modeCameraOption;
503     ToggleButtonInterface*	modeCursorsOption;
504     ToggleButtonInterface*	modePickOption;
505     ToggleButtonInterface*	modeNavigateOption;
506     ToggleButtonInterface*	modePanZoomOption;
507     ToggleButtonInterface*	modeRoamOption;
508     ToggleButtonInterface*	modeRotateOption;
509     ToggleButtonInterface*	modeZoomOption;
510 
511     ToggleButtonInterface*	imageDepth8Option;
512     ToggleButtonInterface*	imageDepth12Option;
513     ToggleButtonInterface*	imageDepth15Option;
514     ToggleButtonInterface*	imageDepth16Option;
515     ToggleButtonInterface*	imageDepth24Option;
516     ToggleButtonInterface*	imageDepth32Option;
517     CommandInterface*	setPanelAccessOption;
518 
519     //
520     // Addition help menu options:
521     //
522     CommandInterface*	onVisualProgramOption;
523 
524     boolean cameraInitialized;
525 
526     //
527     // add a work proc for resetting the execute-on-resize flag because
528     // resize events are async and must be turned off following parseCommonComments.
529     // But before turning it back on, do a sync and wait once.  This is once per
530     // class because doing a sync affects all image windows.  Therefore it's not
531     // necessary to do one for each window.
532     //
533     XtWorkProcId reset_eor_wp;
534     int  pending_resize_x, pending_resize_y;
535     int  pending_resize_width, pending_resize_height;
536     static boolean NeedsSyncForResize;
537 
538   protected:
539 
540     static String  DefaultResources[];
541 
542     //
543     // Creates the editor window workarea (as required by MainWindow class).
544     //
545     virtual Widget createWorkArea(Widget parent);
546 
547     //
548     // Creates the editor window menus (as required by DXWindow class).
549     //
550     virtual void createMenus(Widget parent);
551 
552     //
553     // Creation routine for each of the editor menus:
554     //   Intended to be used in derived class createMenus(), if needed,
555     //   to better control the menu creation, or to be overriden in
556     //   the derived classes.
557     //
558     virtual void createFileMenu(Widget parent);
559     virtual void createWindowsMenu(Widget parent);
560     virtual void createOptionsMenu(Widget parent);
561     virtual void createHelpMenu(Widget parent);
562 
563     //
564     // These routines send messages to the gl rendering portion of the
565     // server software.
566     void sendClientMessage(Atom atom, int num, long  *longs);
sendClientMessage(Atom atom,long oneLong)567     void sendClientMessage(Atom atom, long oneLong)
568     {
569 	this->sendClientMessage(atom, 1, &oneLong);
570     }
sendClientMessage(Atom atom)571     void sendClientMessage(Atom atom)
572     {
573 	this->sendClientMessage(atom, 0, (long*)NULL);
574     }
575     void sendClientMessage(Atom atom, int num, short *shorts);
576     void sendClientMessage(Atom atom, int num, char  *chars);
577     void sendClientMessage(Atom atom, int num, float *floats);
sendClientMessage(Atom atom,float oneFloat)578     void sendClientMessage(Atom atom, float oneFloat)
579     {
580 	this->sendClientMessage(atom, 1, &oneFloat);
581     }
582 
583     void wait4GLAcknowledge();
584 
585     //
586     // Do any image window specific stuff to get the canvas ready for an
587     // image.
588     virtual void newCanvasImage();
589     virtual void trackFrameBuffer(XEvent *event, Boolean *continue_to_dispatch);
590     virtual boolean handleExposures(XEvent *event);
591 
592     virtual void serverDisconnected();
593 
594     void saveImage();
595 
596     //
597     // Set the state and sensitivity of the ImageDepth cascade menu and its
598     // command interfaces.
599     //
600     void configureImageDepthMenu();
601 
602     //
603     // Set the state and sensitivity of the Mode cascade menu and its
604     // command interfaces.
605     //
606     void configureModeMenu();
607 
608 
609     Node *getNodeByInstance(const char *classname, const char *name,
610 					int instance);
611 
612     //
613     // Install the default resources for this class and then call the
614     // same super class method to get the default resources from the
615     // super classes.
616     //
617     virtual void installDefaultResources(Widget baseWidget);
618 
619     //
620     // The superclass has responsibility for the wizard window but here we'll
621     // substitute the application comment for the wizard window.  They look pretty
622     // much the same.
623     //
624     virtual void postWizard();
625 
626     //
627     // Allow subclasses to supply a string for the XmNgeometry resource
628     // (i.e. -geam 90x60-0-0) which we'll use instead of createX,createY,
629     // createWidth, createHeight when making the new window.  If the string
630     // is available then initialize() won't call setGeometry.
631     //
632     virtual void getGeometryAlternateNames(String*, int*, int);
633 
634     //virtual int displayWidth() { return 1280; }
635     //virtual int displayHeight() { return 1024; }
636 
637     //
638     // Rather than triggering an execution following a window resize,
639     // Queue the execution so that it happens soon after the execution
640     // but not immediately after.  This gives better results for users
641     // with window mgrs that deliver tons of resize events
642     //
643     XtIntervalId execute_after_resize_to;
644 
645 
646   public:
647     //
648     // Constructor for the masses:
649     //
650     ImageWindow(boolean  isAnchor, Network* network);
651 
652 
653     //
654     // Destructor:
655     //
656     ~ImageWindow();
657 
658     //
659     // Sets the default resources before calling the superclass
660     // initialize() function.
661     //
662     virtual void initialize();
663 
664     //
665     // Handle client messages (not from the exec).
666     //
667     virtual void notify
668 	(const Symbol message, const void *msgdata=NULL, const char *msg=NULL);
669 
670     //
671     // Redefine unmanage to unmanaged all child dialogs
672     virtual void unmanage();
673 
674     //
675     // Redefine manage to add tracking on frame buffer
676     virtual void manage();
677 
678     //
679     // Redefine setGeometry in order to deal with the WHERE parameter
680     void setGeometry (int x, int y, int width, int height);
681 
682     //
683     // A routine to install all per-canvas callbacks.
684     virtual void installCallbacks();
685 
686     //
687     // Probe and Pick management:
688     //
689     void    addProbe(Node*);
690     void    deleteProbe(Node*);
691     void    changeProbe(Node*);
692     boolean selectProbeByInstance(int instanceNumber);
693     ProbeNode    *getCurrentProbeNode();
694     boolean setCurrentProbe(int instanceNumber);
695 
696     void    addPick(Node*);
697     void    deletePick(Node*);
698     void    changePick(Node*);
699     boolean selectPickByInstance(int instanceNumber);
700     PickNode   *getCurrentPickNode();
701     boolean setCurrentPick(int instanceNumber);
702 
703     //
704     // three functions to control the hightlighting of the Execute button.
705     //
706     virtual void beginExecution();
707     virtual void standBy();
708     virtual void endExecution();
709 
getCanvas()710     Widget getCanvas()
711     {
712 	return this->canvas;
713     }
directInteractionAllowed()714     boolean directInteractionAllowed()
715     {
716 	return this->directInteraction;
717     }
718     void allowDirectInteraction(boolean allow);
719 
720     virtual void clearFrameBufferOverlay();
721 
722     //
723     // Associates an Image or Display style node with an ImageWindow.
724     // Returns TRUE if there wasn't another node already associated, FALSE
725     // if there was.
726     boolean associateNode(Node *n);
getAssociatedNode()727     Node   *getAssociatedNode() { return this->node; }
728     boolean isAssociatedWithNode();
729 
730 
731     boolean enablePerspective(boolean enable);
732     boolean getPerspective();
733     void setViewAngle(double viewAngle);
734     void getViewAngle(double &viewAngle);
735     void setResolution(int x, int y);
736     void getResolution(int &x, int &y);
737     void setWidth(double w);
738     void getWidth(double &w);
739     void setTo(double *v);
740     void setFrom(double *v);
741     void setUp(double *v);
742     void getTo(double *v);
743     void getFrom(double *v);
744     void getUp(double *v);
745     void getThrottle(double &v);
746     void setThrottle(double v);
747     boolean updateThrottleDialog(double v);
748 
749     boolean isAutoAxesCursorSet ();
750     boolean isAutoAxesCornersSet ();
751     boolean isSetAutoAxesFrame ();
752     boolean isSetAutoAxesGrid ();
753     boolean isSetAutoAxesAdjust ();
754     boolean isAutoAxesAnnotationSet ();
755     boolean isAutoAxesLabelsSet ();
756     boolean isAutoAxesColorsSet ();
757     boolean isAutoAxesFontSet ();
758     boolean isAutoAxesTicksSet ();
759     boolean isAutoAxesLabelScaleSet ();
760     boolean isAutoAxesXTickLocsSet ();
761     boolean isAutoAxesYTickLocsSet ();
762     boolean isAutoAxesZTickLocsSet ();
763     boolean isAutoAxesXTickLabelsSet ();
764     boolean isAutoAxesYTickLabelsSet ();
765     boolean isAutoAxesZTickLabelsSet ();
766 
767     boolean isBGColorConnected ();
768     boolean isThrottleConnected ();
769     boolean isRecordEnableConnected ();
770     boolean isRecordFileConnected ();
771     boolean isRecordFormatConnected ();
772     boolean isRecordResolutionConnected ();
773     boolean isRecordAspectConnected ();
774     boolean isAutoAxesEnableConnected ();
775     boolean isAutoAxesCornersConnected ();
776     boolean isAutoAxesCursorConnected ();
777     boolean isAutoAxesFrameConnected ();
778     boolean isAutoAxesGridConnected ();
779     boolean isAutoAxesAdjustConnected ();
780     boolean isAutoAxesAnnotationConnected ();
781     boolean isAutoAxesLabelsConnected ();
782     boolean isAutoAxesColorsConnected ();
783     boolean isAutoAxesFontConnected ();
784     boolean isAutoAxesTicksConnected ();
785     boolean isAutoAxesXTickLocsConnected ();
786     boolean isAutoAxesYTickLocsConnected ();
787     boolean isAutoAxesZTickLocsConnected ();
788     boolean isAutoAxesXTickLabelsConnected ();
789     boolean isAutoAxesYTickLabelsConnected ();
790     boolean isAutoAxesZTickLabelsConnected ();
791     boolean isAutoAxesLabelScaleConnected ();
792     boolean isRenderModeConnected ();
793     boolean isButtonUpApproxConnected ();
794     boolean isButtonDownApproxConnected ();
795     boolean isButtonUpDensityConnected ();
796     boolean isButtonDownDensityConnected ();
797 
798     void getAutoAxesCorners (double dval[]);
799     void getAutoAxesCursor (double *x, double *y, double *z);
800     int getAutoAxesAnnotation (char *sval[]);
801     int getAutoAxesLabels (char *sval[]);
802     int getAutoAxesColors (char *sval[]);
803     int getAutoAxesFont (char *sval);
804     void getAutoAxesTicks (int *t1, int *t2, int *t3);
805     void getAutoAxesTicks (int *t);
806     void getAutoAxesXTickLocs (double **t, int *size);
807     void getAutoAxesYTickLocs (double **t, int *size);
808     void getAutoAxesZTickLocs (double **t, int *size);
809     int getAutoAxesXTickLabels (char *sval[]);
810     int getAutoAxesYTickLabels (char *sval[]);
811     int getAutoAxesZTickLabels (char *sval[]);
812     int getAutoAxesEnable ();
813     double getAutoAxesLabelScale ();
814     int getAutoAxesTicksCount ();
815 
816     void setAutoAxesCorners (double dval[], boolean send);
817     void setAutoAxesCursor (double x, double  y, double  z, boolean send);
818     void setAutoAxesFrame (boolean state, boolean send);
819     void setAutoAxesGrid (boolean state, boolean send);
820     void setAutoAxesAdjust (boolean state, boolean send);
821     void setAutoAxesEnable (int d, boolean send);
822     void setAutoAxesLabelScale (double d, boolean send);
823     void setAutoAxesAnnotation (char *value, boolean send);
824     void setAutoAxesColors (char *value, boolean send);
825     void setAutoAxesLabels (char *value, boolean send);
826     void setAutoAxesFont (char *value, boolean send);
827     void setAutoAxesTicks (int t1, int t2, int t3, boolean send);
828     void setAutoAxesTicks (int t, boolean send);
829     void setAutoAxesXTickLocs (double *t, int size, boolean send);
830     void setAutoAxesYTickLocs (double *t, int size, boolean send);
831     void setAutoAxesZTickLocs (double *t, int size, boolean send);
832     void setAutoAxesXTickLabels (char *value, boolean send);
833     void setAutoAxesYTickLabels (char *value, boolean send);
834     void setAutoAxesZTickLabels (char *value, boolean send);
835 
836     void unsetAutoAxesCorners (boolean send);
837     void unsetAutoAxesCursor (boolean send);
838     void unsetAutoAxesTicks (boolean send);
839     void unsetAutoAxesXTickLocs (boolean send);
840     void unsetAutoAxesYTickLocs (boolean send);
841     void unsetAutoAxesZTickLocs (boolean send);
842     void unsetAutoAxesXTickLabels (boolean send);
843     void unsetAutoAxesYTickLabels (boolean send);
844     void unsetAutoAxesZTickLabels (boolean send);
845     void unsetAutoAxesAnnotation (boolean send);
846     void unsetAutoAxesLabels (boolean send);
847     void unsetAutoAxesColors (boolean send);
848     void unsetAutoAxesFont (boolean send);
849     void unsetAutoAxesEnable (boolean send);
850     void unsetAutoAxesFrame (boolean send);
851     void unsetAutoAxesGrid (boolean send);
852     void unsetAutoAxesAdjust (boolean send);
853     void unsetAutoAxesLabelScale (boolean send);
854 
855     void setTranslateSpeed(double);
856     void setRotateSpeed(double);
857     double getTranslateSpeed();
858     double getRotateSpeed();
859 
860     void setSoftware(boolean sw);
861     void getSoftware(boolean &sw);
862     void setApproximation(boolean up, ApproxMode mode);
863     void getApproximation(boolean up, ApproxMode &mode);
864     void setDensity(boolean up, int density);
865     void getDensity(boolean up, int &density);
866 
867     boolean setInteractionMode(DirectInteractionMode mode);
868     DirectInteractionMode getInteractionMode();
869 
870     void newCamera(int image_width, int image_height);
871     void newCamera(double box[4][3], double aamat[4][4], double *from, double *to,
872 	double *up, int image_width, int image_height, double width,
873 	boolean perspective, double viewAngle);
874     void undoCamera();
875     void redoCamera();
876     void resetCamera();
877     boolean setView(ViewDirection direction);
878     boolean setLook(LookDirection direction);
879     boolean setConstraint(ConstraintDirection direction);
880     ConstraintDirection getConstraint();
881 
882     boolean setBackgroundColor(const char *color);
883     boolean updateBGColorDialog(const char *color);
884     const char *getBackgroundColor();
885     void  setDisplayGlobe();
886 
887     boolean enableRecord(boolean enable);
888     boolean useRecord();
889     boolean setRecordFile(const char *file);
890     boolean setRecordFormat(const char *format);
891     const char *getRecordFile();
892     const char *getRecordFormat();
893     void getRecordResolution(int &x, int &y);
894     double getRecordAspect();
895 
896     //
897     // What to do when we need to reset the window because the server has
898     // forgotten about us.
899     //
900     virtual void resetWindow();
901     //
902     // getDisplayString() returns a static char *.  It goes away on the next
903     // call.  DON'T FREE or DELETE IT!  It returns NULL on error.
904     //
905     char *getDisplayString();
906 
907     //
908     // Change the frame buffer depth of the picture widget
909     //
910     void changeDepth(int depth);
911 
912     //
913     // Post several of the controlling dialogs.
914     //
915     boolean postRenderingOptionsDialog();
916     boolean postAutoAxesDialog();
917     boolean postThrottleDialog();
918     boolean postViewControlDialog();
919     boolean postChangeImageNameDialog();
920     boolean postBackgroundColorDialog();
921     boolean postVPE();
922     boolean postSaveImageDialog();
923     boolean postPrintImageDialog();
924 
925 
926     void sensitizePrintImageDialog(boolean flag);
927     void sensitizeSaveImageDialog(boolean flag);
928     void sensitizeThrottleDialog(boolean flag);
929 
930     //
931     // Get commands.
932     //
getCommandScope()933     CommandScope *getCommandScope() { return this->commandScope; }
getUndoCmd()934     Command *getUndoCmd() { return this->undoCmd; }
getRedoCmd()935     Command *getRedoCmd() { return this->redoCmd; }
getResetCmd()936     Command *getResetCmd() { return this->resetCmd; }
getModeNoneCmd()937     Command *getModeNoneCmd() { return this->modeNoneCmd; }
getModeCameraCmd()938     Command *getModeCameraCmd() { return this->modeCameraCmd; }
getModeCursorsCmd()939     Command *getModeCursorsCmd() { return this->modeCursorsCmd; }
getModePickCmd()940     Command *getModePickCmd() { return this->modePickCmd; }
getModeNavigateCmd()941     Command *getModeNavigateCmd() { return this->modeNavigateCmd; }
getModePanZoomCmd()942     Command *getModePanZoomCmd() { return this->modePanZoomCmd; }
getModeRoamCmd()943     Command *getModeRoamCmd() { return this->modeRoamCmd; }
getModeRotateCmd()944     Command *getModeRotateCmd() { return this->modeRotateCmd; }
getModeZoomCmd()945     Command *getModeZoomCmd() { return this->modeZoomCmd; }
getSetViewNoneCmd()946     Command *getSetViewNoneCmd() { return this->setViewNoneCmd; }
getSetViewTopCmd()947     Command *getSetViewTopCmd() { return this->setViewTopCmd; }
getSetViewBottomCmd()948     Command *getSetViewBottomCmd() { return this->setViewBottomCmd; }
getSetViewFrontCmd()949     Command *getSetViewFrontCmd() { return this->setViewFrontCmd; }
getSetViewBackCmd()950     Command *getSetViewBackCmd() { return this->setViewBackCmd; }
getSetViewLeftCmd()951     Command *getSetViewLeftCmd() { return this->setViewLeftCmd; }
getSetViewRightCmd()952     Command *getSetViewRightCmd() { return this->setViewRightCmd; }
getSetViewDiagonalCmd()953     Command *getSetViewDiagonalCmd() { return this->setViewDiagonalCmd; }
getSetViewOffTopCmd()954     Command *getSetViewOffTopCmd() { return this->setViewOffTopCmd; }
getSetViewOffBottomCmd()955     Command *getSetViewOffBottomCmd() { return this->setViewOffBottomCmd; }
getSetViewOffFrontCmd()956     Command *getSetViewOffFrontCmd() { return this->setViewOffFrontCmd; }
getSetViewOffBackCmd()957     Command *getSetViewOffBackCmd() { return this->setViewOffBackCmd; }
getSetViewOffLeftCmd()958     Command *getSetViewOffLeftCmd() { return this->setViewOffLeftCmd; }
getSetViewOffRightCmd()959     Command *getSetViewOffRightCmd() { return this->setViewOffRightCmd; }
getSetViewOffDiagonalCmd()960     Command *getSetViewOffDiagonalCmd() { return this->setViewOffDiagonalCmd; }
getPerspectiveCmd()961     Command *getPerspectiveCmd() { return this->perspectiveCmd; }
getParallelCmd()962     Command *getParallelCmd() { return this->parallelCmd; }
getConstrainNoneCmd()963     Command *getConstrainNoneCmd() { return this->constrainNoneCmd; }
getConstrainXCmd()964     Command *getConstrainXCmd() { return this->constrainXCmd; }
getConstrainYCmd()965     Command *getConstrainYCmd() { return this->constrainYCmd; }
getConstrainZCmd()966     Command *getConstrainZCmd() { return this->constrainZCmd; }
getLookForwardCmd()967     Command *getLookForwardCmd() { return this->lookForwardCmd; }
getLookLeft45Cmd()968     Command *getLookLeft45Cmd() { return this->lookLeft45Cmd; }
getLookRight45Cmd()969     Command *getLookRight45Cmd() { return this->lookRight45Cmd; }
getLookUp45Cmd()970     Command *getLookUp45Cmd() { return this->lookUp45Cmd; }
getLookDown45Cmd()971     Command *getLookDown45Cmd() { return this->lookDown45Cmd; }
getLookLeft90Cmd()972     Command *getLookLeft90Cmd() { return this->lookLeft90Cmd; }
getLookRight90Cmd()973     Command *getLookRight90Cmd() { return this->lookRight90Cmd; }
getLookUp90Cmd()974     Command *getLookUp90Cmd() { return this->lookUp90Cmd; }
getLookDown90Cmd()975     Command *getLookDown90Cmd() { return this->lookDown90Cmd; }
getLookBackwardCmd()976     Command *getLookBackwardCmd() { return this->lookBackwardCmd; }
getLookAlignCmd()977     Command *getLookAlignCmd() { return this->lookAlignCmd; }
getSoftwareCmd()978     Command *getSoftwareCmd()    { return this->softwareCmd; }
getHardwareCmd()979     Command *getHardwareCmd()    { return this->hardwareCmd; }
getUpNoneCmd()980     Command *getUpNoneCmd()    { return this->upNoneCmd; }
getUpWireframeCmd()981     Command *getUpWireframeCmd()    { return this->upWireframeCmd; }
getUpDotsCmd()982     Command *getUpDotsCmd()    { return this->upDotsCmd; }
getUpBoxCmd()983     Command *getUpBoxCmd()    { return this->upBoxCmd; }
getDownNoneCmd()984     Command *getDownNoneCmd()    { return this->downNoneCmd; }
getDownWireframeCmd()985     Command *getDownWireframeCmd()    { return this->downWireframeCmd; }
getDownDotsCmd()986     Command *getDownDotsCmd()    { return this->downDotsCmd; }
getDownBoxCmd()987     Command *getDownBoxCmd()    { return this->downBoxCmd; }
988 
989     void setAutoAxesDialogTicks();
990     void setAutoAxesDialogFrame();
991     void setAutoAxesDialogGrid();
992     void setAutoAxesDialogAdjust();
993     void setAutoAxesDialogLabels();
994     void setAutoAxesDialogLabelScale();
995     void setAutoAxesDialogFont();
996     void setAutoAxesDialogAnnotationColors();
997     void setAutoAxesDialogCorners();
998     void setAutoAxesDialogCursor();
999     void setAutoAxesDialogEnable();
1000     void setAutoAxesDialogXTickLocs();
1001     void setAutoAxesDialogYTickLocs();
1002     void setAutoAxesDialogZTickLocs();
1003     void setAutoAxesDialogXTickLabels();
1004     void setAutoAxesDialogYTickLabels();
1005     void setAutoAxesDialogZTickLabels();
1006 
1007     void sensitizeViewControl(boolean flag);
1008     void sensitizeChangeImageName(boolean flag);
1009     void sensitizeRenderMode(boolean flag);
1010     void sensitizeButtonUpApprox(boolean flag);
1011     void sensitizeButtonDownApprox(boolean flag);
1012     void sensitizeButtonUpDensity(boolean flag);
1013     void sensitizeButtonDownDensity(boolean flag);
1014 
1015 
1016     //
1017     // Set the title of the window based on this windows associated node
1018     // and whether or not this window is the anchor or not.
1019     // The title will either be the assigned name, the name of the
1020     // associated node or the name of the network file.
1021     //
1022     void resetWindowTitle();
1023 
1024     //
1025     // Allow the DisplayNode to turn off execution on resizes due to
1026     // reading the 'window: pos=... size=...' comments.
1027     //
isExecuteOnResize()1028     boolean isExecuteOnResize() { return this->state.resizeCausesExecution; }
1029     void setExecuteOnResize(boolean setting = TRUE)
1030 				{ this->state.resizeCausesExecution = setting; }
1031     void resetExecuteOnResizeWhenAble();
hasPendingWindowPlacement()1032     boolean hasPendingWindowPlacement() { return (boolean)(this->reset_eor_wp != 0); }
1033 
1034     //
1035     // Before calling the super class method we verify that doing this will
1036     // leave at least one startup image window.  If not, issue an error and
1037     // return without calling the super class method.
1038     //
1039     virtual void toggleWindowStartup();
1040 
1041     Network *getNetwork();
1042 
1043     //
1044     // Update the autoaxes dialog with whatever the current
1045     // values in the ImageNode are data-driven
1046     void updateAutoAxesDialog();
1047     void updateRenderingOptionsDialog();
1048 
1049     //
1050     // Update any displayed information from the new cfg state found in
1051     // the associated ImageNode.
1052     //
1053     void updateFromNewCfgState();
1054 
1055     //
1056     // Allow the node to set the sensitivity of the background
1057     // color dialog box when the associated tab is attached/deattached
1058     // to an arc.
1059     void sensitizeBackgroundColorDialog(boolean flag);
1060 
1061     //
1062     // Determine whether the camera has been initializes
cameraIsInitialized()1063     boolean cameraIsInitialized() { return this->cameraInitialized;}
1064 
1065     //
1066     // Called by the MainWindow CloseCallback.  We call the super class
1067     // method and then, if we are not an anchor and are in DataViewer mode
1068     // then we exit the program.
1069     //
1070     virtual void closeWindow();
1071 
1072     //
1073     // On behalf of ImageFormatDialog (Save/Print Image dialogs) which needs to
1074     // know what strategy to use for saving the current image.
1075     //
hardwareMode()1076     boolean hardwareMode() { return this->state.hardwareRender; }
1077 
1078     //
1079     // Make sure the changing the window title doesn't change the where
1080     // parameter (due to new window placement features.)
1081     //
1082     virtual void setWindowTitle(const char* name, boolean check_geometry=FALSE);
1083 
1084 
1085     //
1086     // Returns a pointer to the class name.
1087     //
getClassName()1088     const char* getClassName()
1089     {
1090 	return ClassImageWindow;
1091     }
1092 };
1093 
1094 
1095 #endif // _ImageWindow_h
1096