b311480e |
1 | // Copyright (c) 1995-1999 Matra Datavision |
2 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
3 | // |
4 | // The content of this file is subject to the Open CASCADE Technology Public |
5 | // License Version 6.5 (the "License"). You may not use the content of this file |
6 | // except in compliance with the License. Please obtain a copy of the License |
7 | // at http://www.opencascade.org and read it completely before using this file. |
8 | // |
9 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
10 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
7fd59977 |
11 | // |
b311480e |
12 | // The Original Code and all software distributed under the License is |
13 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
14 | // Initial Developer hereby disclaims all such warranties, including without |
15 | // limitation, any warranties of merchantability, fitness for a particular |
16 | // purpose or non-infringement. Please see the License for the specific terms |
17 | // and conditions governing the rights and limitations under the License. |
18 | |
19 | // Modified 27/12/98 : FMN ; PERF: OPTIMISATION LOADER (LOPTIM) |
7fd59977 |
20 | |
21 | #include <Image_Image.hxx> |
22 | #include <AlienImage_XAlienImage.hxx> |
23 | #include <OSD_Process.hxx> |
24 | #include <OSD_File.hxx> |
25 | #include <ImageUtility_XPR.ixx> |
26 | |
27 | #define LOPTIM |
28 | #ifndef LOPTIM |
29 | static Handle(AlienImage_XAlienImage) XAlienImage = new AlienImage_XAlienImage(); |
30 | #else |
31 | static Handle(AlienImage_XAlienImage)& _XAlienImage() { |
32 | static Handle(AlienImage_XAlienImage) XAlienImage = new AlienImage_XAlienImage(); |
33 | return XAlienImage; |
34 | } |
35 | #define XAlienImage _XAlienImage() |
36 | #endif // LOPTIM |
37 | |
38 | void ImageUtility_XPR::XPR( |
39 | const Handle(AlienImage_AlienUserImage)& aAlienImage, |
40 | const Standard_CString aName, |
41 | const Standard_CString xprOptions ) |
42 | { if ( aAlienImage->IsKind(STANDARD_TYPE(AlienImage_XAlienImage) ) ) { |
43 | Handle(AlienImage_XAlienImage) aXImage = |
44 | Handle(AlienImage_XAlienImage)::DownCast(aAlienImage) ; |
45 | |
46 | aXImage->SetName( TCollection_AsciiString( aName ) ) ; |
47 | |
48 | XPR( aXImage, xprOptions ) ; |
49 | } |
50 | else { |
51 | XPR( aAlienImage->ToImage(), aName, xprOptions ) ; |
52 | } |
53 | } |
54 | |
55 | void ImageUtility_XPR::XPR( const Handle(Image_Image)& aImage, |
56 | const Standard_CString aName, |
57 | const Standard_CString xprOptions ) |
58 | |
59 | { XAlienImage->Clear() ; |
60 | XAlienImage->FromImage( aImage ) ; |
61 | |
62 | XAlienImage->SetName( TCollection_AsciiString( aName ) ) ; |
63 | |
64 | XPR( XAlienImage, xprOptions ) ; |
65 | } |
66 | |
67 | void ImageUtility_XPR::XPR( |
68 | const Handle(AlienImage_XAlienImage)& aXImage, |
69 | const Standard_CString xprOptions ) |
70 | |
71 | { |
72 | OSD_File File = OSD_File::BuildTemporary() ; |
73 | |
74 | #ifdef TRACE |
75 | OSD_Path Path ; |
76 | TCollection_AsciiString Name ; |
77 | |
78 | File.Path(Path) ; |
79 | |
80 | Path.SystemName( Name ) ; |
81 | |
82 | cout << "BuildTemporaryFile :" << Name << endl << flush ; |
83 | #endif |
84 | |
85 | aXImage->Write( File ) ; |
86 | |
87 | File.Close() ; |
88 | |
89 | XPR( File, xprOptions ) ; |
90 | } |
91 | |
92 | |
93 | void ImageUtility_XPR::XPR( const OSD_File& File, |
94 | const Standard_CString xprOptions ) |
95 | |
96 | { |
97 | TCollection_AsciiString s, Name ; |
98 | OSD_Path Path ; |
99 | OSD_Process Process ; |
100 | |
101 | File.Path( Path ) ; |
102 | |
103 | Path.SystemName( Name, OSD_Default ) ; |
104 | |
105 | XPR( Name.ToCString(), xprOptions ) ; |
106 | } |
107 | |
108 | void ImageUtility_XPR::XPR( const Standard_CString aName, |
109 | const Standard_CString xprOptions ) |
110 | |
111 | { |
112 | TCollection_AsciiString s; |
113 | OSD_Process Process ; |
114 | |
115 | s = TCollection_AsciiString("xpr ") |
116 | + TCollection_AsciiString(xprOptions) |
117 | + TCollection_AsciiString(" ") |
118 | + aName |
119 | + TCollection_AsciiString( " | lpr &" ); |
120 | |
121 | Process.Spawn( s ) ; |
122 | |
123 | } |
124 | |