Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoXtPrintDialog.h
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Dave Immel (MMM yyyy)
25**=======================================================================*/
26/*=======================================================================
27 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
28 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
29 *** ***
30 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
31 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
32 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
33 *** ***
34 *** RESTRICTED RIGHTS LEGEND ***
35 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
36 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
37 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
38 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
39 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
40 *** ***
41 *** COPYRIGHT (C) 1996-2024 BY FEI S.A.S, ***
42 *** BORDEAUX, FRANCE ***
43 *** ALL RIGHTS RESERVED ***
44**=======================================================================*/
45/*=======================================================================
46** Modified by : VSG (MMM YYYY)
47**=======================================================================*/
48
49
50#ifdef _WIN32
51# include <Inventor/Win/SoWinPrintDialog.h>
52#else // _WIN32
53
54#ifndef SO_XT_PRINT_DIALOG_
55#define SO_XT_PRINT_DIALOG_
56
57#include <X11/Intrinsic.h>
58#include <Xm/Xm.h>
59
60#include <Inventor/SbBasic.h>
61#include <Inventor/Xt/SoXtComponent.h>
62#include <Inventor/misc/SoCallbackList.h>
63
64class SbPList;
65class SoNode;
66class SoPath;
68class SoXtPrintDialog;
69
70
71// callback function prototypes
73typedef void SoXtPrintDialogCB(void *userData, SoXtPrintDialog *dialog);
74
76//
77// class: SoXtPrintDialog
78//
80
141 public:
146 SoWidget parent = NULL,
147 const char *name = NULL,
148 SbBool buildInsideParent = TRUE);
153 SoGLRenderAction *act,
154 SoWidget parent = NULL,
155 const char *name = NULL,
156 SbBool buildInsideParent = TRUE);
161
165 void setSceneGraph( SoPath *path );
169 void setSceneGraph( SoNode *root );
170
174 SoNode *getSceneGraph() { return rootNode; }
178 SoPath *getSceneGraphPath() { return rootPath; }
179
188
193 void setPrintSize( const SbVec2f &inches );
198 void setPrintSize( const SbVec2s &pixels );
199
206 inline void setBeforePrintCallback(
207 SoXtPrintDialogCB *f,
208 void *userData = NULL);
215 inline void setAfterPrintCallback(
216 SoXtPrintDialogCB *f,
217 void *userData = NULL);
218
219 private:
220
221 // This constructor takes a boolean whether to build the widget now.
222 // Subclasses can pass FALSE, then call SoXtPrintDialog::buildWidget()
223 // when they are ready for it to be built.
225 SoWidget parent,
226 const char *name,
227 SbBool buildInsideParent,
228 SbBool buildNow);
229
230 // redefine these
231 virtual SbString getDefaultWidgetName() const;
232 virtual SbString getDefaultTitle() const;
233 virtual SbString getDefaultIconTitle() const;
234
235 SoNode *rootNode;
236 SoPath *rootPath;
237 SbBool printDone;
238 SbBool highQuality;
239 SbBool portraitFormat;
240 SbBool printerOutput, postScriptOutput;
241 SbBool nodeMostRecent;
242 SbBool WYSIWYGflag;
243 SoWidget messageWidget, printButton, quitButton;
244 SoWidget messageLabelWidget, fileFormatWidget;
245 SoWidget toPrinterWidget, toPostScriptFileWidget, toRGBFileWidget;
246 SoWidget printerHorizSize, printerVertSize;
247 SoWidget postScriptHorizSize, postScriptVertSize;
248 SoWidget rgbHorizSize, rgbVertSize;
249 SoWidget printerDPIField, postScriptDPIField;
250 SoWidget rgbFilenameWidget, postScriptFilenameWidget;
251 SbPList *printers;
252 char *defaultPrinter;
253 int whichPrinter; // index into printers list
254 SbVec2f printSize;
255 SbVec2s printRes;
256 SoCallbackList beforeList, afterList;
257 SbBool alreadyUpdated;
258
259 void print(); // called by printCallback
260 void getPrinterList();
261 void printToPostScript( SoNode *, char *, int, int );
262
263 // Methods used to build the print dialog.
264 void buildToPrinterWidget( SoWidget parent );
265 void buildToPostScriptFileWidget( SoWidget parent );
266 void buildToRGBFileWidget( SoWidget parent );
267 void placeBottomOfDialog( SoXtPrintDialog * );
268 void buildRadioButton( char *, char *, char *, int, int,
269 SoWidget, XtCallbackProc );
270 void buildSizeFields( char *, int, SoWidget, SoWidget &, SoWidget &,
271 XtCallbackProc, XtCallbackProc );
272 void buildDPIField( int, SoWidget, SoWidget &, XtCallbackProc );
273 void updateTextports();
274
275 //
276 // Callback routines.
277 //
278 static void qualityCB( SoWidget, SoXtPrintDialog *,
279 XmAnyCallbackStruct * );
280 static void pageFormatCB( SoWidget, SoXtPrintDialog *,
281 XmAnyCallbackStruct * );
282 static void fileFormatCB( SoWidget, SoXtPrintDialog *,
283 XmAnyCallbackStruct * );
284 static void printerHorizSizeCB( SoWidget, SoXtPrintDialog *,
285 XmAnyCallbackStruct * );
286 static void printerVertSizeCB( SoWidget, SoXtPrintDialog *,
287 XmAnyCallbackStruct * );
288 static void postScriptHorizSizeCB( SoWidget, SoXtPrintDialog *,
289 XmAnyCallbackStruct * );
290 static void postScriptVertSizeCB( SoWidget, SoXtPrintDialog *,
291 XmAnyCallbackStruct * );
292 static void rgbHorizSizeCB( SoWidget, SoXtPrintDialog *,
293 XmAnyCallbackStruct * );
294 static void rgbVertSizeCB( SoWidget, SoXtPrintDialog *,
295 XmAnyCallbackStruct * );
296 static void printerDPICB( SoWidget, SoXtPrintDialog *,
297 XmAnyCallbackStruct * );
298 static void postScriptDPICB( SoWidget, SoXtPrintDialog *,
299 XmAnyCallbackStruct * );
300 static void outputCB( SoWidget, SoXtPrintDialog *,
301 XmAnyCallbackStruct * );
302 static void printCB( SoWidget, SoXtPrintDialog *,
303 XmAnyCallbackStruct * );
304 static void quitCB( SoWidget, SoXtPrintDialog *,
305 XmAnyCallbackStruct * );
306 static void listPick( SoWidget, SoXtPrintDialog *ml,
307 XmAnyCallbackStruct * );
308
309 // SoWidget for controlling the Print Style
310 SoWidget styleButton;
311 int currentStyle;
312
313 private:
314 // Builds the widget.
315 SoWidget buildWidget(SoWidget parent);
316
317 // this is called by both constructors
318 void constructorCommon(SbBool buildNow);
319
320
321};
322
323// Inline methods
324void
326 SoXtPrintDialogCB *f,
327 void *userData )
328{
329 beforeList.clearCallbacks();
330 beforeList.addCallback((SoCallbackListCB *) f, userData);
331}
332
333void
335 SoXtPrintDialogCB *f,
336 void *userData )
337{
338 afterList.clearCallbacks();
339 afterList.addCallback((SoCallbackListCB *) f, userData);
340}
341
342
343#endif /* SO_XT_PRINT_DIALOG_ */
344
345#endif // _WIN32
346
347
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
Abstract base class for all Open Inventor components.
Dialog box for controlling printing.
SoGLRenderAction * getGLRenderAction()
Gets the render action to be used when printing.
void setAfterPrintCallback(SoXtPrintDialogCB *f, void *userData=NULL)
Two callbacks are maintained, one which gets called just before a print is executed,...
void setPrintSize(const SbVec2f &inches)
Sets the size of the printed image in inches.
SoPath * getSceneGraphPath()
Gets the path to nodes to be used for printing.
void SoXtPrintDialogCB(void *userData, SoXtPrintDialog *dialog)
void setBeforePrintCallback(SoXtPrintDialogCB *f, void *userData=NULL)
Two callbacks are maintained, one which gets called just before a print is executed,...
SoXtPrintDialog(SoWidget parent=NULL, const char *name=NULL, SbBool buildInsideParent=TRUE)
Constructor.
void setGLRenderAction(const SoGLRenderAction *act)
Sets the render action to be used when printing.
void setPrintSize(const SbVec2s &pixels)
Sets the size of the printed image in pixels.
~SoXtPrintDialog()
Destructor.
SoXtPrintDialog(SoGLRenderAction *act, SoWidget parent=NULL, const char *name=NULL, SbBool buildInsideParent=TRUE)
Constructor that takes a render action.
SoNode * getSceneGraph()
Gets the root node to be used for printing.
void setSceneGraph(SoNode *root)
Sets the root node to be used for printing.
void setSceneGraph(SoPath *path)
Sets the path to nodes to be used for printing.
int SbBool
Boolean type.
Definition SbBase.h:87