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 _EditorWindow_h
14 #define _EditorWindow_h
15 
16 #include "List.h"
17 #include "Command.h"
18 #include "DXWindow.h"
19 #include "ControlPanel.h"
20 #include "Cacheability.h"
21 #include "InsertNetworkDialog.h"
22 #include "Stack.h"
23 
24 typedef long NodeStatusChange;
25 
26 //
27 // Class name definition:
28 //
29 #define ClassEditorWindow	"EditorWindow"
30 
31 //
32 // XtCallbackProc (*CB), XtEventHandler (*EH) and XtActionProc (*AP)
33 // DialogCallback (*DCB), XtInputCallbackProc (*ICP), XtWorkProc (*WP)
34 // functions for this and derived classes
35 //
36 extern "C" void EditorWindow_EditMenuMapCB(Widget, XtPointer, XtPointer);
37 extern "C" void EditorWindow_WindowMenuMapCB(Widget, XtPointer, XtPointer);
38 extern "C" void EditorWindow_FileMenuMapCB(Widget, XtPointer, XtPointer);
39 extern "C" void EditorWindow_OptionsMenuMapCB(Widget, XtPointer, XtPointer);
40 extern "C" void EditorWindow_SetDecoratorStyleCB(Widget, XtPointer, XtPointer);
41 extern "C" boolean EditorWindow_ConvertSelectionCB(Widget, Atom *, Atom *, Atom *,
42 	XtPointer *, unsigned long *, int *);
43 extern "C" void EditorWindow_LoseSelectionCB(Widget, Atom *);
44 extern "C" void EditorWindow_SelectionDoneCB(Widget, Atom *, Atom *);
45 extern "C" void EditorWindow_SelectionReadyCB (Widget , XtPointer , Atom *,
46 	Atom *, XtPointer , unsigned long *, int *);
47 
48 
49 //
50 // Referenced classes:
51 //
52 class Network;
53 class CommandScope;
54 class CommandInterface;
55 class ControlPanel;
56 class NodeDefinition;
57 class ToolSelector;
58 class EditorWorkSpace;
59 class WorkSpaceComponent;
60 class VPERoot;
61 class Ark;
62 class Node;
63 class StandIn;
64 class FindToolDialog;
65 class GridDialog;
66 class CreateMacroDialog;
67 class InsertNetworInsertNetworkkDialog;
68 class List;
69 class NoUndoEditorCommand;
70 class DeleteNodeCommand;
71 class PanelAccessManager;
72 class PanelGroupManager;
73 class ControlPanelGroupDialog;
74 class ProcessGroupCreateDialog;
75 class ProcessGroupAssignDialog;
76 class DXApplication;
77 class DeferrableAction;
78 class CascadeMenu;
79 class Dialog;
80 class Decorator;
81 class DecoratorStyle;
82 class GetSetConversionDialog;
83 class TransmitterNode;
84 class GraphLayout;
85 class VPEAnnotator;
86 class XHandler;
87 class UndoableAction;
88 
89 #if WORKSPACE_PAGES
90 class GroupManager;
91 class GroupRecord;
92 class PageGroupManager;
93 class AnnotationGroupManager;
94 class Dictionary;
95 class PageSelector;
96 #endif
97 
98 //
99 // EditorWindow class definition:
100 //
101 class EditorWindow : public DXWindow
102 {
103   friend class DXApplication;	// For the constructor
104   friend class NoUndoEditorCommand;
105   friend class DeleteNodeCommand;
106   friend class UndoDeletion; // for createNetFileFromSelection
107   friend class PageSelector; // for setCommandActivation() in PageSelector::selectPage()
108   friend ControlPanel::~ControlPanel();
109 
110   private:
111     //
112     // Private class data:
113     //
114     static boolean ClassInitialized;
115     static String DefaultResources[];
116     static String SequenceNet[];
117     friend void EditorWindow_FileMenuMapCB(Widget, XtPointer, XtPointer);
118     friend void EditorWindow_OptionsMenuMapCB(Widget, XtPointer, XtPointer);
119     friend void EditorWindow_WindowMenuMapCB(Widget, XtPointer, XtPointer);
120     friend void EditorWindow_EditMenuMapCB(Widget, XtPointer, XtPointer);
121     friend void EditorWindow_SetDecoratorStyleCB(Widget, XtPointer, XtPointer);
122     friend boolean EditorWindow_ConvertSelectionCB(Widget, Atom *, Atom *, Atom *,
123 	XtPointer *, unsigned long *, int *);
124     friend void EditorWindow_LoseSelectionCB(Widget, Atom *);
125     friend void EditorWindow_SelectionDoneCB(Widget, Atom *, Atom *);
126     friend void EditorWindow_SelectionReadyCB (Widget , XtPointer , Atom *,
127 	Atom *, XtPointer , unsigned long *, int *);
128     static boolean KeyHandler(XEvent *event, void *clientData);
129 
130     static void SetOwner(void*);
131     static void DeleteSelections(void*);
132     static void Select(void*);
133 
134     boolean	   initialNetwork;
135     FindToolDialog *findToolDialog;
136     Dialog 	   *printProgramDialog;
137     Dialog 	   *saveAsCCodeDialog;
138     GridDialog     *gridDialog;
139     ProcessGroupCreateDialog *processGroupCreateDialog;
140     ProcessGroupAssignDialog *processGroupAssignDialog;
141     ControlPanelGroupDialog  *panelGroupDialog;
142     CreateMacroDialog	     *createMacroDialog;
143     InsertNetworkDialog	     *insertNetworkDialog;
144     Network	   *pendingPaste;
145     char	   *copiedNet;
146     char 	   *copiedCfg;
147 
148     void postProcessGroupCreateDialog();
149     void postPanelGroupDialog();
150     void postGridDialog();
151     void postFindToolDialog();
152     void postPrintProgramDialog();
153     void postSaveAsCCodeDialog();
154     void postCreateMacroDialog();
155     void postInsertNetworkDialog();
156     void selectNodes(int how);
157 
158     //
159     // Used to defer the calls to setCommandActivation() when used with
160     // this->deferrableCommandActivation.
161     // We allow for the ability to defer the activation when
162     // it is known that an operation will cause an activation.  For example
163     // when many selections are done, it is sufficient to to a single
164     // activation at the end of the operation instead of for each selection.
165     //
166     //
167     static void	SetCommandActivation(void *editor, void *requestData);
168 
169     //
170     // Origin of the workspace window, used for error node finding
171     // and for 'restore' in the find tool dialog.
172     //
173     int    Ox, Oy;
174     char*  find_restore_page;
175 
176     void   openSelectedINodes();
177 
178     //
179     // Virtual function called at the beginning/end of Command::execute
180     // We must turn off tool selection and make sure the cursor is
181     // back to the normal cursor (i.e. not the Tool placement cursor).
182     //
183     virtual void beginCommandExecuting();
184 
185 
186     //
187     // This is a helper method for this->areSelectedNodesMacrofiable().
188     // It recursively descends the connections from the given node to determine
189     // if it connected to a selected node.  If ignoreDirectConnect is TRUE,
190     // then we do not care about selected nodes that are directly connected
191     // to selected nodes.
192     // Returns TRUE if there is a downstream selected node, otherwise FALSE.
193     //
194     boolean isSelectedNodeDownstream(Node *srcNode,boolean ignoreDirectConnect);
195 
196     //
197     // Just call Network's method to optimize output cacheability.
198     //
199     void optimizeNodeOutputCacheability();
200 
201 #ifndef FORGET_GETSET
202     //
203     // Convert nets to use GetLocal/Global and SetLocal/Global
204     // instead of Get and Set (nodes).
205     //
206            void postGetSetConversionDialog();
207     static void ConvertToLocal();
208     static void ConvertToGlobal(boolean global = TRUE);
209 
210     void convertToGlobal(boolean global);
211 
212     static Command*  SelectedToGlobalCmd;
213     static Command*  SelectedToLocalCmd;
214 
215     CascadeMenu		*programVerifyCascade;
216 
217     Command		*toGlobalCmd;
218     Command		*toLocalCmd;
219     Command		*postGetSetCmd;
220 
221     static GetSetConversionDialog* GetSetDialog;
222 #endif
223 
224     //
225     // This is the last TransmitterNode that was seen to go through
226     // handleNodeStatusChange().  We use this to allow the ReceiverNode
227     // to hook itself to if non-NULL.
228     //
229     TransmitterNode *lastSelectedTransmitter;
230 
231     //
232     // Record each node as it's highlighted during and execution.  Later on we
233     // can change the label colors to show what executed.  The list should be
234     // cleared whenever the net gets marked dirty.
235     // set transmitters_added to TRUE after examining executed_nodes for connections
236     // to transmitters/receivers.  It would be possible to add transmitters/recievers
237     // as the executed_nodes list is built up, however it saves time to do it only
238     // if the user requests the operation, so transmitters_added tells us if we've
239     // done it already or not.
240     //
241     // Record the executing node because if it's in a page which hasn't been populated
242     // yet, it won't turn green.  If you populate the page after its module started
243     // executing, then need some way to turn the standin green.  This is provided
244     // as a member field and not static because you could (I think) have 2 standins
245     // green at the same time - if 1 were a MacroNode and the other were in the the
246     // vpe for that macro.
247     //
248     List* executed_nodes;
249     List* errored_standins;
250     Node* executing_node;
251     boolean transmitters_added;
252     void resetExecutionList();
253     void resetErrorList(boolean reset_all=TRUE);
resetColorList()254     void resetColorList() { this->resetExecutionList(); this->resetErrorList(); }
255 
256     //
257     // Automatic graph layout
258     //
259     GraphLayout* layout_controller;
260 
261     //
262     // Record moved StandIns and decorators so that movement
263     // can be undone. ...on behalf of the new graph layout operation.
264     //
265     Stack undo_list;
266     boolean moving_many_standins;
267     boolean performing_undo;
268     boolean creating_new_network;
269     void clearUndoList();
270 
271   protected:
272     //
273     // State information:
274     //
275     Network*			network;
276     ControlPanel		*currentPanel;
277     boolean			panelVisible;
278     boolean			hit_detection;
279 
280     //
281     // Used to defer the calls to setCommandActivation().
282     //
283     DeferrableAction	*deferrableCommandActivation;
284 
285     //
286     // Editor commands:
287     //
288     Command*		undoCmd;
289     Command*		toolPanelCmd;
290     Command*		hitDetectionCmd;
291     Command*		showExecutedCmd;
292     Command*		newControlPanelCmd;
293     Command*		openControlPanelCmd;
294     Command*            valuesCmd;
295     Command*            addInputTabCmd;
296     Command*            removeInputTabCmd;
297     Command*            addOutputTabCmd;
298     Command*            removeOutputTabCmd;
299     Command*            hideAllTabsCmd;
300     Command*            revealAllTabsCmd;
301     Command*            deleteNodeCmd;
302     Command*            cutNodeCmd;
303     Command*            copyNodeCmd;
304     Command*            pasteNodeCmd;
305     Command*            selectAllNodeCmd;
306     Command*            selectConnectedNodeCmd;
307     Command*            selectUnconnectedNodeCmd;
308     Command*            selectUpwardNodeCmd;
309     Command*            selectDownwardNodeCmd;
310     Command*            deselectAllNodeCmd;
311     Command*		selectUnselectedNodeCmd;
312     Command*		editMacroNameCmd;
313     Command*		editCommentCmd;
314     Command*            findToolCmd;
315     Command*            insertNetCmd;
316     Command*            addAnnotationCmd;
317     Command*            macroifyCmd;
318 #if WORKSPACE_PAGES
319     Command*            pagifyCmd;
320     Command*            pagifySelectedCmd;
321     Command*            moveSelectedCmd;
322     Command*            autoChopSelectedCmd;
323     Command*            autoFuseSelectedCmd;
324     Command*            deletePageCmd;
325     Command*            configurePageCmd;
326 #endif
327     Command*		javifyNetCmd;
328     Command*		unjavifyNetCmd;
329     Command*		reflowGraphCmd;
330     Command*            gridCmd;
331     Command*		setPanelGroupCmd;
332     Command*		setPanelAccessCmd;
333     Command*		closeCmd;
334     Command*		printProgramCmd;
335     Command*		saveAsCCodeCmd;
336     Command*		createProcessGroupCmd;
337     Command*		openImageCmd;
338     Command*		openMacroCmd;
339     Command*		openColormapCmd;
340     Command*		cacheAllOutputsCmd;
341     Command*		cacheLastOutputsCmd;
342     Command*		cacheNoOutputsCmd;
343     Command*		showCacheAllOutputsCmd;
344     Command*		showCacheLastOutputsCmd;
345     Command*		showCacheNoOutputsCmd;
346     Command*		optimizeCacheabilityCmd;
347 
348     //
349     // Editor components:
350     //
351     //
352     ToolSelector	*toolSelector;
353 #if WORKSPACE_PAGES
354     PageSelector	*pageSelector;
355 #endif
356     VPERoot		*workSpace;
357     Widget		scrolledWindow;
358 
359     //
360     // Menus & pulldowns:
361     //
362     Widget		fileMenu;
363     Widget		editMenu;
364     Widget		windowsMenu;
365     Widget		optionsMenu;
366 
367     Widget		fileMenuPulldown;
368     Widget		editMenuPulldown;
369     Widget		windowsMenuPulldown;
370     Widget		optionsMenuPulldown;
371 
372     //
373     // File menu options:
374     //
375     CommandInterface*	newOption;
376     CommandInterface*	openOption;
377     CommandInterface*	loadMacroOption;
378     CommandInterface*	loadMDFOption;
379     CommandInterface*	saveOption;
380     CommandInterface*	saveAsOption;
381     CascadeMenu*	settingsCascade;
382     CommandInterface*	saveCfgOption;
383     CommandInterface*	openCfgOption;
384     CommandInterface*	printProgramOption;
385     CommandInterface*	saveAsCCodeOption;
386     CommandInterface*	quitOption;
387     CommandInterface*	closeOption;
388 
389     //
390     // Edit menu options:
391     //
392     CommandInterface*	valuesOption;
393     CommandInterface*	findToolOption;
394     CascadeMenu		*editTabsCascade;
395     CommandInterface*	addInputTabOption;
396     CommandInterface*	removeInputTabOption;
397     CascadeMenu		*editSelectCascade;
398     CascadeMenu		*outputCacheabilityCascade;
399     CascadeMenu		*editOutputCacheabilityCascade;
400 #if WORKSPACE_PAGES
401     CascadeMenu		*pageCascade;
402 #endif
403     CascadeMenu		*javaCascade;
404     CommandInterface*	deleteOption;
405     CommandInterface*	cutOption;
406     CommandInterface*	copyOption;
407     CommandInterface*	pasteOption;
408     CommandInterface*	macroNameOption;
409     CommandInterface*	reflowGraphOption;
410     CommandInterface*	undoOption;
411     CommandInterface*	insertNetworkOption;
412     CommandInterface*	addAnnotationOption;
413     CommandInterface*	createMacroOption;
414     CommandInterface*	commentOption;
415     CommandInterface*	createProcessGroupOption;
416     CommandInterface*	assignProcessGroupOption;
417 
418     //
419     // Windows menu options:
420     //
421     CommandInterface*	newControlPanelOption;
422     CommandInterface*	openControlPanelOption;
423     CommandInterface*	openAllControlPanelsOption;
424     CommandInterface*	openControlPanelByNameOption;
425     CascadeMenu		*openControlPanelByNameMenu;
426     CommandInterface*	openMacroOption;
427     CommandInterface*	openImageOption;
428     CommandInterface*	openColormapEditorOption;
429     CommandInterface*   messageWindowOption;
430 
431     //
432     // Options menu options:
433     //
434     CommandInterface*	toolPalettesOption;
435     CommandInterface*	hitDetectionOption;
436     CommandInterface*	gridOption;
437     CommandInterface*	panelGroupOption;
438     CommandInterface*	panelAccessOption;
439     CommandInterface*	showExecutedOption;
440 
441     //
442     // Help menu options:
443     //
444     CommandInterface*	onVisualProgramOption;
445 
446 #if 00
447     void newNetwork();
448 #endif
449     void drawArks();
450 
451 
452     //
453     // Creates the editor window workarea (as required by MainWindow class).
454     //
455     virtual Widget createWorkArea(Widget parent);
456 
457     //
458     // Creates the editor window menus (as required by DXWindow class).
459     //
460     virtual void createMenus(Widget parent);
461 
462     //
463     // Creation routine for each of the editor menus:
464     //   Intended to be used in derived class createMenus(), if needed,
465     //   to better control the menu creation, or to be overriden in
466     //   the derived classes.
467     //
468     virtual void createFileMenu(Widget parent);
469     virtual void createEditMenu(Widget parent);
470     virtual void createWindowsMenu(Widget parent);
471     virtual void createOptionsMenu(Widget parent);
472     virtual void createHelpMenu(Widget parent);
473 
474 
475     //
476     // De/Activate any commands that have to do with editing.
477     // Should be called when a node is added or deleted or there is a selection
478     //
479     // Called through deferrableCommandActivation via SetCommandActivation(),
480     // but this can also be called directly.  It is used to set the activation
481     // state of all commands owned by the Editor.
482     // FIXME: should this be virtual?
483     //
484     void setCommandActivation();
485 
486     //
487     // Perform various command functions.
488     //
489     boolean selectDownwardNodes();
490     boolean selectUpwardNodes();
491     boolean selectConnectedNodes();
492     boolean selectUnconnectedNodes();
493     boolean setSelectedNodeTabVisibility(boolean v);
494     boolean selectConnection(int direction, boolean connected);
495     //
496     // Implements the 'Add/Remove Input/Output Tab' commands.
497     // If 'adding' is TRUE, we ADD either inputs or outputs, otherwise
498     // REMOVE.
499     // If 'input' is true, we operate on the input parameters, otherwise
500     // the outputs.
501     //
502     boolean editSelectedNodeTabs(boolean adding, boolean input);
503 
504     //
505     // Methods that are used by the DeleteCommand to help implement
506     // undelete.
507     //
508     void	removeSelectedNodes();
509 #ifdef OBSOLETE
510     void 	restoreRemovedNodes(List *toRestore);
511 #endif
512     void 	deleteNodes(List *toDelete);
513 
514     virtual void serverDisconnected();
515 
516     //
517     // Edit/{Cut,Copy,Paste} operations
518     //
519     boolean	cutSelectedNodes();
520     boolean	copySelectedNodes(boolean delete_property = FALSE);
521     boolean	pasteCopiedNodes();
522     char*       createNetFileFromSelection(int& net_len, char** cfg_out, int& cfg_len);
523     boolean     setPendingPaste (const char* net_file_name,
524 	    const char* cfg_file_name, boolean ignoreUndefinedModules=FALSE);
525 
526     //
527     // When the user clicks the Edit/Add Decorator option, we create a new
528     // decorator, stick it in a list.  Then a callback in EditorWorkSpace
529     // will let us know when the user clicks in the workspace.  The
530     // decorator(s) is the list will be added to the workspace at that location.
531     // Any decorator in this list is not yet managed.
532     // This list increases is size in an extern C callback, not thru NoUndoEditorCommand
533     // because it is modal in nature.  The coding is copied from ControlPanel which
534     // does the same thing when adding either interactors or decorators.
535     //
536     List *addingDecorators;
537 
538     //
539     // Constructor:
540     //  THIS CONSTRUCTOR SHOULD NEVER BE CALLED FROM ANYWHERE BUT
541     //  DXApplication::newNetworkEditor OR A SUBCLASS OF NETWORK.  ANY
542     //  SUBCLASSES CONSTRUCTOR SHOULD ONLY BE CALLED FROM A VIRTUAL
543     //  REPLACEMENT OF DXApplication::newNetworkEditor.
544     //
545     EditorWindow(boolean  isAnchor, Network* network);
546 
547     //
548     // Install the default resources for this class and then call the
549     // same super class method to get the default resources from the
550     // super classes.
551     //
552     virtual void installDefaultResources(Widget baseWidget);
553 
554 #if WORKSPACE_PAGES
555     EditorWorkSpace *getPage(const char *name);
556     Dictionary      *pageDictionary;
557     GroupRecord	    *getGroupOfWorkSpace(EditorWorkSpace*);
558     int		     getPageMemberCount(WorkSpace*);
559     void	     destroyStandIns(List*);
560 #endif
561 
562     //
563     // Do what ever is necessary just before changing the current network.
564     // To make things run faster we turn off line routing.  This should
565     // be followed by a call to endNetworkChange(), which will re-enable
566     // line routing.
567     //
568     void beginNetworkChange();
569     void endNetworkChange();
570 
571     //
572     // Put up a little dialog with page configuration options
573     //
574     boolean configurePage();
575 
576     //
577     // Prepare to place a new decorator (vpe annotation)
578     //
579     boolean placeDecorator();
580 
581     //
582     // In addition to setting command activation based on undo_list size,
583     // also set the text of the undo button label.
584     //
585     void setUndoActivation();
586 
587     // work around for a motif bug - hitting pg up,down in the vpe crashes dxui
588     XHandler* pgKeyHandler;
589 
590     boolean keyHandler(XEvent* event);
591 
592   public:
593 
594     //
595     // Flags for highlighting nodes.
596     //
597     enum {
598 	   ERRORHIGHLIGHT,
599 	   EXECUTEHIGHLIGHT,
600 	   REMOVEHIGHLIGHT
601 	 };
602 
603     //
604     // Destructor:
605     //
606     ~EditorWindow();
607 
608     //
609     // this->workSpace subclasses off EditorWorkSpace but is no longer an EditorWorkSpace
610     //
getWorkSpace()611     EditorWorkSpace *getWorkSpace() { return (EditorWorkSpace*)this->workSpace; }
612 
613     //
614     // look through the network list and make a list of all selected  nodes.
615     // If no selected interactors were found then NULL is returned.
616     // The return list must be freed by the caller.
617     //
618     List *makeSelectedNodeList(const char *classname = NULL);
619     List *makeSelectedDecoratorList();
620 
621     //
622     // Look through the node list and make a list of existing module names.
623     //
624     List *makeModuleList();
625 
626     //
627     // EditorWorkSpace needs access to the object to support drag-n-drop
628     //
getToolSelector()629     ToolSelector *getToolSelector() { return this->toolSelector; };
630 
631     //
632     // Properly deal with a nodes status change.
633     // Currently, this only include selection and deselection.
634     //
635     void handleNodeStatusChange(Node *n, NodeStatusChange status);
handleDecoratorStatusChange()636     void handleDecoratorStatusChange() { this->setCommandActivation(); }
637 
638     //
639     // Determine the number of selected nodes
640     //
641     int getNodeSelectionCount(const char *classname = NULL);
642 
643     //
644     // Highlighting node.
645     //
646     void highlightNodes(int flag, List *l = NULL);
647     void highlightNode(Node *n, int flag);
648     void highlightNode(const char* name, int instance, int flag);
649     boolean selectNode(Node *node, boolean select, boolean moveto = TRUE);
650     boolean selectNode(char* name, int instance, boolean select);
651     boolean selectDecorator (VPEAnnotator* dec, boolean select, boolean moveto=TRUE);
652     void selectUnselectedNodes();
653     void deselectAllNodes();
654     void selectAllNodes();
655 
656     //
657     // Process group fuctions.
658     //
659 #if WORKSPACE_PAGES
660     void setGroup(GroupRecord *grec, Symbol groupID);
661     void resetGroup(const char* name, Symbol groupID);
662     void selectGroup(const char* name, Symbol groupID);
663     void clearGroup(const char* name, Symbol groupID);
664     boolean changeGroup (const char* old_group, const char* new_name, Symbol groupID);
665 #else
666     void setProcessGroup(const char* name);
667     void resetProcessGroup(const char* name);
668     void selectProcessGroup(const char* name);
669     void clearProcessGroup(const char* name);
670 #endif
671 
672     //
673     // Handle client messages (not from the exec).
674     //
675     virtual void notify
676 	(const Symbol message, const void *msgdata=NULL, const char *msg=NULL);
677 
678     //
679     // Sets the tool panel to be visible or invisible
680     // based on the current state.
681     //
682     void toggleToolPanel();
683     void doSelectedNodesDefaultAction();
684 
685     //
686     // Change the label color of standins whose nodes ran in the most recent
687     // execution
688     //
689     boolean showExecutedNodes();
690 
691     //
692     // look through the network list for selected nodes
693     // and open the configuration dialog associated with
694     // the node.
695     //
696     void openSelectedNodesCDB();
697 
698     //
699     // Implements the 'Values' command.
700     //
701     void showValues();
702 
703     // EditorWindow cursor functions
704     void setCursor(int cursorType);
705     void resetCursor();
706 
707     //
708     // add the node selected in the toolList to the vpe at x,y
709     // Added stitch 11/8/02.  When it's set to TRUE, we're going to handle
710     // conflicts of node type/inst # by replacing the copy in the merging
711     // network with the copy in the real network.  This is useful in
712     // implemented Undo of Cut/Delete.  For this we need to copy not only
713     // selected nodes, but also nodes they're wired to so that we can
714     // restore the wires that were broken as a result of the cut.
715     //
716     void addCurrentNode(int x, int y, EditorWorkSpace *where, boolean stitch=FALSE);
717     void addNode (NodeDefinition *, int x, int y, EditorWorkSpace *where);
718 
719     //
720     // Move the workspace window if the selected error node is not shown
721     //
722     void moveWorkspaceWindow(UIComponent*);
723 
724     //
725     // Move the workSpace inside the scrolled window so that the given x,y
726     // position is at the upper left corner of the scrolled window unless
727     // centered is TRUE in which case x,y is the center of the scrolled
728     // window.  Currently only implmented for x=y=0 && centered == FALSE.
729     //
730     void moveWorkspaceWindow(int x, int y, boolean centered = TRUE);
731 
732     //
733     // Supply scrollbar positions so that they can be recorded/reset when
734     // switching pages.
735     //
736     void getWorkspaceWindowPos (int *x, int *y);
737 
738 
739     //
740     // Reset the origin flag
741     //
resetOrigin()742     void resetOrigin()
743     {
744 	this->Ox = -1;
745     }
746 
747     //
748     // Data access routines:
749     //
getNetwork()750     Network* getNetwork()
751     {
752 	return this->network;
753     }
754 
755     //
756     // Return a pointer to the editor's notion of the 'current' ControlPanel.
757     // The return panel may or may not be managed.
758     //
759     virtual ControlPanel *getCurrentControlPanel(void);
760 
761 
getScrolledWindow()762     Widget  getScrolledWindow()
763     {
764 	return this->scrolledWindow;
765     }
766 
isPanelVisible()767     boolean isPanelVisible()
768     {
769 	return this->panelVisible;
770     }
771 
772     void newNode(Node *n, EditorWorkSpace *where);
773     void newDecorator(Decorator* dec, EditorWorkSpace* where=NUL(EditorWorkSpace*));
774 
775     //
776     // notify the a standIn that an arc has been added/deleted to/from the node
777     //
778     void notifyArk(Ark *a, boolean added=TRUE);
779 
getFindDialog()780     FindToolDialog* getFindDialog()
781     {
782 	return (findToolDialog);
783     }
784 
785     virtual void manage();
786 
787     void installWorkSpaceInfo(WorkSpaceInfo *info);
788 
getDeleteNodeCmd()789     Command *getDeleteNodeCmd(){return this->deleteNodeCmd;};
790 #ifndef FORGET_GETSET
GetGlobalCmd()791     static Command* GetGlobalCmd()
792 	{ return EditorWindow::SelectedToGlobalCmd; };
GetLocalCmd()793     static Command* GetLocalCmd()
794 	{ return EditorWindow::SelectedToLocalCmd; };
795 #endif
796 
797 
798     //
799     // Do what ever is necessary just before and after reading a new network
800     // These should be called in pairs.
801     //
802     void prepareForNewNetwork();
803     void completeNewNetwork();
804 
805     //
806     // Notify control panel related dialogs of the change of panel list.
807     //
808     void notifyCPChange(boolean newList = TRUE);
809 
810     //
811     // Adjust the name of the editor window based on the current network
812     // name.
813     //
814     void resetWindowTitle();
815 
816     void    openSelectedMacros();
817     void    openSelectedImageWindows();
818     boolean anySelectedNodes(const char *classname);
819     boolean anySelectedColormaps();
820     boolean anySelectedMacros();
821     boolean anySelectedDisplayNodes();
822 
823     //
824     // Turn selected nodes into a macro
825     //
826     virtual boolean macroifySelectedNodes(const char *name,
827 					  const char *cat,
828 					  const char *desc,
829 					  const char *fileName);
830 
831     //
832     // Turn selected nodes into a vpe page
833     //
834 #if WORKSPACE_PAGES
835     virtual boolean pagifySelectedNodes(boolean require_selected_nodes=FALSE);
836     virtual boolean pagifySelectedNodes(EditorWorkSpace* );
837     virtual boolean postMoveSelectedDialog();
838     virtual boolean autoChopSelectedNodes();
839     virtual boolean autoFuseSelectedNodes();
getMoveSelectedCmd()840 	    Command *getMoveSelectedCmd() { return this->moveSelectedCmd; }
841 	    boolean pagifyNetNodes
842 		(Network* tmpnet, EditorWorkSpace*, boolean try_current_page = FALSE );
843     virtual boolean deletePage(const char* page_name=NUL(char*));
844     void moveStandIns
845 	(EditorWorkSpace *page, List *selectedNodes, int xoff, int yoff, List *dl);
846     void moveDecorators
847 	(EditorWorkSpace *page, List *seldec, int xoff, int yoff, List *nl);
848 #endif
849     EditorWorkSpace *getNodesBBox
850 	(int *minx, int *miny, int *maxx, int *maxy, List *l, List *dl);
851 
852     //
853     // Change the decorator style of the selected decorator(s)
854     //
855     void setDecoratorStyle (List *decors, DecoratorStyle *newds);
856 
857 #if 11
858     void newNetwork();
859 #endif
860 
861     //
862     // Print the visual program as a PostScript file using geometry and not
863     // bitmaps.  We set up the page so that it maps to the current workspace
864     // and then as the StandIns and ArkStandIns to print themselves.
865     // If the scale allows and the label_parameters arg is set, then
866     // label the parameters and display the values.
867     // We return FALSE and issue and error message if an error occurs.
868     //
869     boolean printVisualProgramAsPS(const char *filename,
870 				    float x_pagesize, float y_pagesize,
871 				    boolean label_parameters);
872     boolean printVisualProgramAsPS(FILE*, const char* filename, float x_pagesize,
873 	float y_pagesize, boolean label_parameters, EditorWorkSpace*, int, int);
874 
875     //
876     // Set the cacheability of all outputs of the selected tools to one of
877     // OutputFullyCached, OutputNotCached or OutputCacheOnce.
878     // A warning is issued on those nodes that do not have writeable
879     // cacheability.
880     //
881     void setSelectedNodesOutputCacheability(Cacheability c);
882 
883     //
884     // Show (select) the nodes with given cacheability
885     // OutputFullyCached, OutputNotCached or OutputCacheOnce.
886     //
887     void selectNodesWithOutputCacheability(Cacheability c);
888 
889     //
890     // Determine if the currently selected set of nodes is macrofiable.  In
891     // particular, we check for selections that would result in an output
892     // being connected to on input of the newly created macro.  To do this
893     // we look at each selected node and determine if its immediate downstream
894     // unselected nodes are connected (possibly through intermediate nodes)
895     // to another of the selected nodes.
896     // Returns TRUE if macrofiable, else returns FALSE and issues and error
897     // message.
898     //
899     boolean areSelectedNodesMacrofiable();
900 
901 #if WORKSPACE_PAGES
902     //
903     // Determine if the currently selected set of nodes is pagifiable.
904     // This means that no selected node has an arc to an unselected node.
905     // The only way data flow into or out of a page is thru Input, Output,
906     // Transmitter, Receiver nodes.
907     // The report flag tells if we should report failure to the user via
908     // an ErrorMessage.
909     boolean areSelectedNodesPagifiable(boolean report=FALSE);
910 
911     void    populatePage(EditorWorkSpace* ews);
getPageSelector()912     PageSelector* getPageSelector() { return this->pageSelector; }
913 
914     //
915     // Help for Network::mergeNetworks().  It's wrong to use {begin,end}NetworkChnage
916     // because that would operate on all pages.  They operate only on the current page.
917     // Aside: the current page better not change in between calls to begin, end.
918     // It would be just as dangerous to record the page upon which the operation was
919     // initiated because the page could be deleted.
920     //
921     void beginPageChange();
922     void endPageChange();
923     void	removeNodes(List* toDelete);
924 #endif
925 
926     TransmitterNode *getMostRecentTransmitterNode();
927 
928 #if EXPOSE_SET_SELECTION
929     //
930     // On behalf of VPEAnnotators which have the ability to snarf whole nets and
931     // set them back into the selection via XtOwnSelection...
932     //
933     void setCopiedNet(const char*);
934 #endif
935 
936     //
937     // Change a resource in the Workspace widget that lets the user know
938     // if things will overlap - during the course of moving
939     //
940     boolean toggleHitDetection();
941 
942     //
943     // Create a special java page and fill it up.
944     //
945     boolean javifyNetwork();
946     boolean unjavifyNetwork();
947 
948     //
949     // Use GraphLayout to modify the flow of the graph.
950     //
951     boolean reflowEntireGraph();
952 
953     //
954     // register undo information
955     //
956     void  saveLocationForUndo (UIComponent* uic, boolean mouse=FALSE, boolean same_event=FALSE);
957     void  saveAllLocationsForUndo (UndoableAction* gridding);
958     void  beginMultipleCanvasMovements();
endMultipleCanvasMovements()959     void  endMultipleCanvasMovements() { this->moving_many_standins = FALSE; }
960 
961     //
962     // a mechanism for Node to notify us that his definition has changed.  We
963     // throw out the undo list because this will probably involve changes that
964     // we can't work around i.e. types of io tabs will be different and attempts
965     // to reconnect tabs will fail.
966     //
notifyDefinitionChange(Node * n)967     void notifyDefinitionChange(Node* n) { this->clearUndoList(); }
968 
969     //
970     // perform undo operation
971     //
972     boolean undo();
973 
974     //
975     // Receive a notification that the net has been saved and marked clean
976     //
notifySaved()977     void notifySaved() { this->clearUndoList(); }
978 
979     //
980     // FindToolDialog requires support in order to move the canvas back
981     // the original location before the first find operation.  This used
982     // to happen via a side effect in moveWorkspaceWindow() which was
983     // broken with the addition of vpe pages.
984     //
985     void checkPointForFindDialog(FindToolDialog*);
986 
987     //
988     // Returns a pointer to the class name.
989     //
getClassName()990     const char* getClassName()
991     {
992 	return ClassEditorWindow;
993     }
994 };
995 
996 
997 #endif // _EditorWindow_h
998