Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoWinPrintDialog.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2023 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23
24
25
26#ifndef SO_WIN_PRINT_DIALOG_
27#define SO_WIN_PRINT_DIALOG_
28
29#ifndef DONT_DOC
30
31#ifdef _WIN32
32// Not currently implemented for _WIN32
33#else
34
35#include <Xm/Xm.h>
36
37#include <Inventor/SbBasic.h>
38#include <Inventor/Win/SoWinComponent.h>
39#include <Inventor/misc/SoCallbackList.h>
40
41class SbPList;
42class SoNode;
43class SoPath;
45class SoWinPrintDialog;
46
47
48// callback function prototypes
49typedef void SoWinPrintDialogCB(void *userData, SoWinPrintDialog *dialog);
50
52//
53// class: SoWinPrintDialog
54//
56
57{
58 public:
59 // Constructors and destructor.
60 SoWinPrintDialog(
61 SoWidget parent = NULL,
62 const char *name = NULL,
63 SbBool buildInsideParent = TRUE);
64 SoWinPrintDialog(
66 SoWidget parent = NULL,
67 const char *name = NULL,
68 SbBool buildInsideParent = TRUE);
69 ~SoWinPrintDialog();
70
71 // Sets/gets the node to be used for printing
72 void setSceneGraph( SoPath *path );
73 void setSceneGraph( SoNode *root );
74
75 SoNode *getSceneGraph() { return rootNode; }
76 SoPath *getSceneGraphPath() { return rootPath; }
77
78 void setGLRenderAction(const SoGLRenderAction *act);
79 SoGLRenderAction *getGLRenderAction();
80
81 // Sets the size of the printing
82 void setPrintSize( const SbVec2f &s );
83 void setPrintSize( const SbVec2s &s );
84
85 // These two callbacks are used before and after a print
86 // action is performed.
87 inline void setBeforePrintCallback(
88 SoWinPrintDialogCB *f,
89 void *userData = NULL);
90 inline void setAfterPrintCallback(
91 SoWinPrintDialogCB *f,
92 void *userData = NULL);
93
94 private:
95
96 // This constructor takes a boolean whether to build the widget now.
97 // Subclasses can pass FALSE, then call SoWinPrintDialog::buildWidget()
98 // when they are ready for it to be built.
99 SoWinPrintDialog(
100 SoWidget parent,
101 const char *name,
102 SbBool buildInsideParent,
103 SbBool buildNow);
104
105 // redefine these
106 virtual SbString getDefaultWidgetName() const;
107 virtual SbString getDefaultTitle() const;
108 virtual SbString getDefaultIconTitle() const;
109
110 SoNode *rootNode;
111 SoPath *rootPath;
112 SbBool printDone;
113 SbBool highQuality;
114 SbBool portraitFormat;
115 SbBool printerOutput, postScriptOutput;
116 SbBool nodeMostRecent;
117 SbBool WYSIWYGflag;
118 SoWidget messageWidget, printButton, quitButton;
119 SoWidget messageLabelWidget, fileFormatWidget;
120 SoWidget toPrinterWidget, toPostScriptFileWidget, toRGBFileWidget;
121 SoWidget printerHorizSize, printerVertSize;
122 SoWidget postScriptHorizSize, postScriptVertSize;
123 SoWidget rgbHorizSize, rgbVertSize;
124 SoWidget printerDPIField, postScriptDPIField;
125 SoWidget rgbFilenameWidget, postScriptFilenameWidget;
126 SbPList *printers;
127 char *defaultPrinter;
128 int whichPrinter; // index into printers list
129 SbVec2f printSize;
130 SbVec2s printRes;
131 SoCallbackList beforeList, afterList;
132 SbBool alreadyUpdated;
133
134 void print(); // called by printCallback
135 void getPrinterList();
136 void printToPostScript( SoNode *, char *, int, int );
137
138 // Methods used to build the print dialog.
139 void buildToPrinterWidget( SoWidget parent );
140 void buildToPostScriptFileWidget( SoWidget parent );
141 void buildToRGBFileWidget( SoWidget parent );
142 void placeBottomOfDialog( SoWinPrintDialog * );
143 void buildRadioButton( char *, char *, char *, int, int,
144 SoWidget, XtCallbackProc );
145 void buildSizeFields( char *, int, SoWidget, SoWidget &, SoWidget &,
146 XtCallbackProc, XtCallbackProc );
147 void buildDPIField( int, SoWidget, SoWidget &, XtCallbackProc );
148 void updateTextports();
149
150 //
151 // Callback routines.
152 //
153 static void qualityCB( SoWidget, SoWinPrintDialog *,
154 XmAnyCallbackStruct * );
155 static void pageFormatCB( SoWidget, SoWinPrintDialog *,
156 XmAnyCallbackStruct * );
157 static void fileFormatCB( SoWidget, SoWinPrintDialog *,
158 XmAnyCallbackStruct * );
159 static void printerHorizSizeCB( SoWidget, SoWinPrintDialog *,
160 XmAnyCallbackStruct * );
161 static void printerVertSizeCB( SoWidget, SoWinPrintDialog *,
162 XmAnyCallbackStruct * );
163 static void postScriptHorizSizeCB( SoWidget, SoWinPrintDialog *,
164 XmAnyCallbackStruct * );
165 static void postScriptVertSizeCB( SoWidget, SoWinPrintDialog *,
166 XmAnyCallbackStruct * );
167 static void rgbHorizSizeCB( SoWidget, SoWinPrintDialog *,
168 XmAnyCallbackStruct * );
169 static void rgbVertSizeCB( SoWidget, SoWinPrintDialog *,
170 XmAnyCallbackStruct * );
171 static void printerDPICB( SoWidget, SoWinPrintDialog *,
172 XmAnyCallbackStruct * );
173 static void postScriptDPICB( SoWidget, SoWinPrintDialog *,
174 XmAnyCallbackStruct * );
175 static void outputCB( SoWidget, SoWinPrintDialog *,
176 XmAnyCallbackStruct * );
177 static void printCB( SoWidget, SoWinPrintDialog *,
178 XmAnyCallbackStruct * );
179 static void quitCB( SoWidget, SoWinPrintDialog *,
180 XmAnyCallbackStruct * );
181 static void listPick( SoWidget, SoWinPrintDialog *ml,
182 XmAnyCallbackStruct * );
183
184 // SoWidget for controlling the Print Style
185 SoWidget styleButton;
186 int currentStyle;
187
188 private:
189 // Builds the widget.
190 SoWidget buildWidget(SoWidget parent);
191
192 // this is called by both constructors
193 void constructorCommon(SbBool buildNow);
194};
195
196// Inline methods
198void
199SoWinPrintDialog::setBeforePrintCallback(
200 SoWinPrintDialogCB *f,
201 void *userData )
202{
203 beforeList.clearCallbacks();
204 beforeList.addCallback((SoCallbackListCB *) f, userData);
205}
206
207void
208SoWinPrintDialog::setAfterPrintCallback(
209 SoWinPrintDialogCB *f,
210 void *userData )
211{
212 afterList.clearCallbacks();
213 afterList.addCallback((SoCallbackListCB *) f, userData);
214}
216
217#endif //_WIN32
218
219#endif
220#endif /* SO_WIN_PRINT_DIALOG_ */
221
List of generic (void *) pointers.
Definition SbPList.h:77
Class for smart character strings.
Definition SbString.h:202
2D vector class.
Definition SbVec.h:76
2D vector class.
Definition SbVec.h:700
Manages a list of callbacks and associated data.
void addCallback(SoCallbackListCB *f, void *userData=NULL)
Adds a function to the list of callback functions.
void clearCallbacks()
Clears all callback functions from the list.
Renders a scene graph using Open Inventor's Render Engine.
Abstract base class for all database nodes.
Definition SoNode.h:145
Path that points to a list of hierarchical nodes.
Definition SoPath.h:187
int SbBool
Boolean type.
Definition SbBase.h:87