2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 // e-mail t-hartl@muenchen.matra-dtv.fr
17 /************************************************************************/
19 /************************************************************************/
23 #pragma comment( lib, "comdlg32.lib" )
27 #include <Aspect_GradientBackground.hxx>
28 #include <Aspect_Grid.hxx>
29 #include <Aspect_Window.hxx>
30 #include <Bnd_Box.hxx>
33 #include <Graphic3d_Group.hxx>
34 #include <Graphic3d_Structure.hxx>
35 #include <Graphic3d_TextureEnv.hxx>
36 #include <Graphic3d_Vector.hxx>
37 #include <Quantity_Color.hxx>
38 #include <Standard_MultiplyDefined.hxx>
39 #include <Standard_NotImplemented.hxx>
40 #include <Standard_TypeMismatch.hxx>
41 #include <V3d_BadValue.hxx>
42 #include <V3d_Light.hxx>
43 #include <V3d_UnMapped.hxx>
44 #include <V3d_View.hxx>
45 #include <V3d_Viewer.hxx>
56 //**********************************************************************
60 //**********************************************************************
64 memset(&_pd, 0, sizeof(PRINTDLG));
67 _pd.lStructSize = sizeof(PRINTDLG);
70 //**********************************************************************
75 if (_pd.hDevNames) GlobalFree(_pd.hDevNames);
76 if (_pd.hDevMode) GlobalFree(_pd.hDevMode);
77 if (_pd.hDC) DeleteDC(_pd.hDC);
81 //=============================================================================
84 //=============================================================================
85 Standard_Boolean V3d_View::Print (const Aspect_Handle thePrintDC,
86 const Standard_Boolean theShowDialog,
87 const Standard_Boolean theShowBackground,
88 const Standard_CString theFilename,
89 const Aspect_PrintAlgo thePrintAlgorithm) const
92 if (myView->IsDefined())
94 if (thePrintDC != NULL)
96 return myView->Print (thePrintDC, theShowBackground, theFilename, thePrintAlgorithm);
99 if (device._pd.hDC == NULL || theShowDialog)
102 DeleteDC (device._pd.hDC);
105 device._pd.Flags = PD_RETURNDC | PD_NOSELECTION | PD_RETURNDEFAULT;
109 device._pd.Flags = PD_RETURNDC | PD_NOSELECTION;
113 ispd = PrintDlg((LPPRINTDLG)(&(device._pd)));
117 return Standard_False;
120 if (!(device._pd.hDC))
122 if (device._pd.hDevNames)
124 GlobalFree (device._pd.hDevNames);
125 device._pd.hDevNames = NULL;
127 if (device._pd.hDevMode)
129 GlobalFree (device._pd.hDevMode);
130 device._pd.hDevMode = NULL;
132 MessageBox (0, "Couldn't create Printer Device Context", "Error", MB_OK | MB_ICONSTOP);
133 return Standard_False;
137 // process scale factor accordingly to the new printing approach
138 DEVMODE* aMode = (LPDEVMODE)GlobalLock(device._pd.hDevMode);
140 // convert percents to multiplication factor, 100% = 1.0
141 Standard_Real aScaleFactor = (Standard_Real) aMode->dmScale / 100.0;
142 GlobalUnlock (device._pd.hDevMode);
143 return myView->Print (device._pd.hDC, theShowBackground, theFilename, thePrintAlgorithm, aScaleFactor);
146 Standard_NotImplemented::Raise ("V3d_View::Print is implemented only on Windows");
148 return Standard_False;