Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created by: THA |
973c2be1 | 2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 3 | // |
973c2be1 | 4 | // This file is part of Open CASCADE Technology software library. |
b311480e | 5 | // |
d5f74e42 | 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 | |
973c2be1 | 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. | |
b311480e | 11 | // |
973c2be1 | 12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. | |
b311480e | 14 | |
7fd59977 | 15 | // e-mail t-hartl@muenchen.matra-dtv.fr |
16 | ||
17 | /************************************************************************/ | |
18 | /* Includes */ | |
19 | /************************************************************************/ | |
20 | ||
57c28b61 | 21 | #ifdef _WIN32 |
7fd59977 | 22 | #include <windows.h> |
7c65581d | 23 | #if defined(_MSC_VER) |
24 | #pragma comment( lib, "comdlg32.lib" ) | |
25 | #endif | |
7fd59977 | 26 | #endif |
27 | ||
42cf5bc1 | 28 | |
42cf5bc1 | 29 | #include <Aspect_GradientBackground.hxx> |
30 | #include <Aspect_Grid.hxx> | |
31 | #include <Aspect_Window.hxx> | |
32 | #include <Bnd_Box.hxx> | |
33 | #include <gp_Ax3.hxx> | |
34 | #include <gp_Dir.hxx> | |
35 | #include <Graphic3d_Group.hxx> | |
36 | #include <Graphic3d_Structure.hxx> | |
37 | #include <Graphic3d_TextureEnv.hxx> | |
38 | #include <Graphic3d_Vector.hxx> | |
39 | #include <Quantity_Color.hxx> | |
40 | #include <Standard_MultiplyDefined.hxx> | |
7fd59977 | 41 | #include <Standard_NotImplemented.hxx> |
42cf5bc1 | 42 | #include <Standard_TypeMismatch.hxx> |
43 | #include <V3d_BadValue.hxx> | |
42cf5bc1 | 44 | #include <V3d_Light.hxx> |
45 | #include <V3d_UnMapped.hxx> | |
46 | #include <V3d_View.hxx> | |
47 | #include <V3d_Viewer.hxx> | |
7fd59977 | 48 | |
57c28b61 | 49 | #ifdef _WIN32 |
7fd59977 | 50 | struct Device |
51 | { | |
52 | Device(); | |
53 | ~Device(); | |
54 | ||
55 | PRINTDLG _pd; | |
56 | }; | |
57 | ||
58 | //********************************************************************** | |
59 | ||
60 | static Device device; | |
61 | ||
62 | //********************************************************************** | |
63 | ||
64 | Device::Device() | |
65 | { | |
66 | memset(&_pd, 0, sizeof(PRINTDLG)); | |
67 | _pd.hDevNames = NULL; | |
68 | _pd.hDevMode = NULL; | |
69 | _pd.lStructSize = sizeof(PRINTDLG); | |
70 | } | |
71 | ||
72 | //********************************************************************** | |
73 | ||
74 | Device::~Device() | |
75 | { | |
76 | // :TODO: | |
77 | if (_pd.hDevNames) GlobalFree(_pd.hDevNames); | |
78 | if (_pd.hDevMode) GlobalFree(_pd.hDevMode); | |
79 | if (_pd.hDC) DeleteDC(_pd.hDC); | |
80 | } | |
81 | #endif | |
82 | ||
c357e426 | 83 | //============================================================================= |
c85385c0 | 84 | //function : Print |
c357e426 | 85 | //purpose : |
86 | //============================================================================= | |
87 | Standard_Boolean V3d_View::Print (const Aspect_Handle thePrintDC, | |
88 | const Standard_Boolean theShowDialog, | |
89 | const Standard_Boolean theShowBackground, | |
90 | const Standard_CString theFilename, | |
91 | const Aspect_PrintAlgo thePrintAlgorithm) const | |
7fd59977 | 92 | { |
57c28b61 | 93 | #ifdef _WIN32 |
c357e426 | 94 | if (myView->IsDefined()) |
95 | { | |
96 | if (thePrintDC != NULL) | |
97 | { | |
98 | return myView->Print (thePrintDC, theShowBackground, theFilename, thePrintAlgorithm); | |
99 | } | |
100 | ||
101 | if (device._pd.hDC == NULL || theShowDialog) | |
102 | { | |
103 | if (device._pd.hDC) | |
104 | DeleteDC (device._pd.hDC); | |
105 | if (!theShowDialog) | |
106 | { | |
107 | device._pd.Flags = PD_RETURNDC | PD_NOSELECTION | PD_RETURNDEFAULT; | |
108 | } | |
109 | else | |
110 | { | |
111 | device._pd.Flags = PD_RETURNDC | PD_NOSELECTION; | |
112 | } | |
113 | ||
114 | BOOL ispd; | |
115 | ispd = PrintDlg((LPPRINTDLG)(&(device._pd))); | |
116 | ||
117 | if (!ispd) | |
118 | { | |
119 | return Standard_False; | |
120 | } | |
121 | ||
122 | if (!(device._pd.hDC)) | |
123 | { | |
124 | if (device._pd.hDevNames) | |
125 | { | |
126 | GlobalFree (device._pd.hDevNames); | |
127 | device._pd.hDevNames = NULL; | |
128 | } | |
129 | if (device._pd.hDevMode) | |
130 | { | |
131 | GlobalFree (device._pd.hDevMode); | |
132 | device._pd.hDevMode = NULL; | |
133 | } | |
134 | MessageBox (0, "Couldn't create Printer Device Context", "Error", MB_OK | MB_ICONSTOP); | |
135 | return Standard_False; | |
136 | } | |
137 | } | |
7edf74fd A |
138 | |
139 | // process scale factor accordingly to the new printing approach | |
140 | DEVMODE* aMode = (LPDEVMODE)GlobalLock(device._pd.hDevMode); | |
141 | ||
142 | // convert percents to multiplication factor, 100% = 1.0 | |
143 | Standard_Real aScaleFactor = (Standard_Real) aMode->dmScale / 100.0; | |
144 | GlobalUnlock (device._pd.hDevMode); | |
c357e426 | 145 | return myView->Print (device._pd.hDC, theShowBackground, theFilename, thePrintAlgorithm, aScaleFactor); |
146 | } | |
7fd59977 | 147 | #else |
c85385c0 | 148 | (void )thePrintDC; |
149 | (void )theShowDialog; | |
150 | (void )theShowBackground; | |
151 | (void )theFilename; | |
152 | (void )thePrintAlgorithm; | |
c357e426 | 153 | Standard_NotImplemented::Raise ("V3d_View::Print is implemented only on Windows"); |
7fd59977 | 154 | #endif |
7edf74fd | 155 | return Standard_False; |
7fd59977 | 156 | } |