summaryrefslogtreecommitdiff
path: root/src/ImageUtility/ImageUtility_XPR.cxx
blob: 016b7b824b244a05c54a51601fd6b61fa6acf3e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Modified	27/12/98 : FMN ; PERF: OPTIMISATION LOADER (LOPTIM)
//

#include <Image_Image.hxx>
#include <AlienImage_XAlienImage.hxx>
#include <OSD_Process.hxx>
#include <OSD_File.hxx>
#include <ImageUtility_XPR.ixx>

#define LOPTIM
#ifndef LOPTIM
static Handle(AlienImage_XAlienImage) XAlienImage = new AlienImage_XAlienImage();
#else 
static Handle(AlienImage_XAlienImage)& _XAlienImage() {
    static Handle(AlienImage_XAlienImage) XAlienImage = new AlienImage_XAlienImage();
return XAlienImage;
}
#define XAlienImage _XAlienImage()
#endif // LOPTIM

void ImageUtility_XPR::XPR( 
		const Handle(AlienImage_AlienUserImage)& aAlienImage,
		const Standard_CString aName,
		const Standard_CString xprOptions )
{ if ( aAlienImage->IsKind(STANDARD_TYPE(AlienImage_XAlienImage) ) ) {
   	Handle(AlienImage_XAlienImage) aXImage =
		Handle(AlienImage_XAlienImage)::DownCast(aAlienImage) ;

	aXImage->SetName( TCollection_AsciiString( aName ) ) ;

	XPR( aXImage, xprOptions ) ;
  }
  else {
    XPR( aAlienImage->ToImage(), aName, xprOptions ) ;
  }
}

void ImageUtility_XPR::XPR( const Handle(Image_Image)& aImage,
	     			    const Standard_CString aName,
				    const Standard_CString xprOptions )

{ XAlienImage->Clear() ;
  XAlienImage->FromImage( aImage ) ;

  XAlienImage->SetName( TCollection_AsciiString( aName ) ) ;

  XPR( XAlienImage, xprOptions ) ;
}

void ImageUtility_XPR::XPR( 
	const Handle(AlienImage_XAlienImage)& aXImage,
	const Standard_CString xprOptions )

{ 
  OSD_File File = OSD_File::BuildTemporary() ;

#ifdef TRACE
  OSD_Path Path ;
  TCollection_AsciiString Name ;

  File.Path(Path) ;

  Path.SystemName( Name ) ;

  cout << "BuildTemporaryFile :" << Name << endl << flush ;
#endif

  aXImage->Write( File ) ;

  File.Close() ;

  XPR( File, xprOptions ) ;
}


void ImageUtility_XPR::XPR( const OSD_File& File,
				    const Standard_CString xprOptions )

{ 
  TCollection_AsciiString s, Name ;
  OSD_Path Path ;
  OSD_Process Process ;

  File.Path( Path ) ;

  Path.SystemName( Name, OSD_Default ) ;

  XPR( Name.ToCString(), xprOptions ) ;
}

void ImageUtility_XPR::XPR( const Standard_CString aName,
				    const Standard_CString xprOptions )

{ 
  TCollection_AsciiString s;
  OSD_Process Process ;

  s = TCollection_AsciiString("xpr ") 
	+ TCollection_AsciiString(xprOptions) 
	+ TCollection_AsciiString(" ") 
	+ aName
	+ TCollection_AsciiString( " | lpr &" );

  Process.Spawn( s ) ;

}