mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-05 18:16:23 +03:00
0022649: Export to EMF not available
This commit is contained in:
parent
aa17232c48
commit
5cedc27f81
@ -630,7 +630,8 @@ is
|
||||
EF_TEX,
|
||||
EF_PDF,
|
||||
EF_SVG,
|
||||
EF_PGF
|
||||
EF_PGF,
|
||||
EF_EMF
|
||||
|
||||
end ExportFormat;
|
||||
|
||||
|
@ -1321,17 +1321,23 @@ is
|
||||
-- or insufficient system memory available.
|
||||
---Warning: Works only under Windows.
|
||||
|
||||
|
||||
Export( me: mutable;
|
||||
FileName : CString from Standard;
|
||||
Format : ExportFormat from Graphic3d;
|
||||
SortType : SortType from Graphic3d;
|
||||
W, H : Integer from Standard;
|
||||
View : CView from Graphic3d;
|
||||
Under, Over : CLayer2d from Aspect;
|
||||
Precision : Real from Standard = 0.005;
|
||||
ProgressBarFunc : Address from Standard = NULL;
|
||||
ProgressObject : Address from Standard = NULL ) is deferred;
|
||||
theFileName : CString from Standard;
|
||||
theFormat : ExportFormat from Graphic3d;
|
||||
theSortType : SortType from Graphic3d;
|
||||
theWidth, theHeight : Integer from Standard;
|
||||
theView : CView from Graphic3d;
|
||||
theLayerUnder : CLayer2d from Aspect;
|
||||
theLayerOver : CLayer2d from Aspect;
|
||||
thePrecision : Real from Standard = 0.005;
|
||||
theProgressBarFunc : Address from Standard = NULL;
|
||||
theProgressObject : Address from Standard = NULL )
|
||||
returns Boolean from Standard
|
||||
is deferred;
|
||||
---Purpose:
|
||||
-- Export scene into the one of the Vector graphics formats (SVG, PS, PDF...).
|
||||
-- In contrast to Bitmaps, Vector graphics is scalable (so you may got quality benefits on printing to laser printer).
|
||||
-- Notice however that results may differ a lot and do not contain some elements.
|
||||
|
||||
RemovePrimitiveArray( me : mutable;
|
||||
theCGroup : CGroup from Graphic3d;
|
||||
|
@ -9,16 +9,17 @@
|
||||
/************************************************************************/
|
||||
|
||||
|
||||
void Graphic3d_GraphicDriver::Export( const Standard_CString FileName,
|
||||
const Graphic3d_ExportFormat Format,
|
||||
const Graphic3d_SortType aSortType,
|
||||
const Standard_Integer W,
|
||||
const Standard_Integer H,
|
||||
const Graphic3d_CView& View,
|
||||
const Aspect_CLayer2d& Under,
|
||||
const Aspect_CLayer2d& Over,
|
||||
const Standard_Real Precision,
|
||||
const Standard_Address ProgressBarFunc,
|
||||
const Standard_Address ProgressObject )
|
||||
Standard_Boolean Graphic3d_GraphicDriver::Export (const Standard_CString theFileName,
|
||||
const Graphic3d_ExportFormat theFormat,
|
||||
const Graphic3d_SortType theSortType,
|
||||
const Standard_Integer theW,
|
||||
const Standard_Integer theH,
|
||||
const Graphic3d_CView& theView,
|
||||
const Aspect_CLayer2d& theLayerUnder,
|
||||
const Aspect_CLayer2d& theLayerOver,
|
||||
const Standard_Real thePrecision,
|
||||
const Standard_Address theProgressBarFunc,
|
||||
const Standard_Address theProgressObject)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
@ -1235,15 +1235,24 @@ is
|
||||
|
||||
|
||||
Export( me: mutable;
|
||||
FileName : CString from Standard;
|
||||
Format : ExportFormat from Graphic3d;
|
||||
SortType : SortType from Graphic3d;
|
||||
W, H : Integer from Standard;
|
||||
View : CView from Graphic3d;
|
||||
Under, Over : CLayer2d from Aspect;
|
||||
Precision : Real from Standard = 0.005;
|
||||
ProgressBarFunc : Address from Standard = NULL;
|
||||
ProgressObject : Address from Standard = NULL ) is redefined virtual;
|
||||
theFileName : CString from Standard;
|
||||
theFormat : ExportFormat from Graphic3d;
|
||||
theSortType : SortType from Graphic3d;
|
||||
theWidth, theHeight : Integer from Standard;
|
||||
theView : CView from Graphic3d;
|
||||
theLayerUnder : CLayer2d from Aspect;
|
||||
theLayerOver : CLayer2d from Aspect;
|
||||
thePrecision : Real from Standard = 0.005;
|
||||
theProgressBarFunc : Address from Standard = NULL;
|
||||
theProgressObject : Address from Standard = NULL )
|
||||
returns Boolean from Standard
|
||||
is redefined virtual;
|
||||
---Purpose:
|
||||
-- Export scene into the one of the Vector graphics formats (SVG, PS, PDF...).
|
||||
-- Requires gl2ps library.
|
||||
-- In contrast to Bitmaps, Vector graphics is scalable (so you may got quality benefits on printing to laser printer).
|
||||
-- Notice however that results may differ a lot and do not contain some elements.
|
||||
-- EMF export format requiers modified gl2ps library and available only on Windows platform.
|
||||
|
||||
|
||||
SetDepthTestEnabled( me; view : CView from Graphic3d;
|
||||
|
@ -11,92 +11,106 @@
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* Print Methods */
|
||||
/************************************************************************/
|
||||
|
||||
void OpenGl_GraphicDriver::Export( const Standard_CString FileName,
|
||||
const Graphic3d_ExportFormat Format,
|
||||
const Graphic3d_SortType aSortType,
|
||||
const Standard_Integer W,
|
||||
const Standard_Integer H,
|
||||
const Graphic3d_CView& View,
|
||||
const Aspect_CLayer2d& Under,
|
||||
const Aspect_CLayer2d& Over,
|
||||
const Standard_Real Precision,
|
||||
const Standard_Address ProgressBarFunc,
|
||||
const Standard_Address ProgressObject )
|
||||
Standard_Boolean OpenGl_GraphicDriver::Export (const Standard_CString theFileName,
|
||||
const Graphic3d_ExportFormat theFormat,
|
||||
const Graphic3d_SortType theSortType,
|
||||
const Standard_Integer theWidth,
|
||||
const Standard_Integer theHeight,
|
||||
const Graphic3d_CView& theView,
|
||||
const Aspect_CLayer2d& theLayerUnder,
|
||||
const Aspect_CLayer2d& theLayerOver,
|
||||
const Standard_Real /*thePrecision*/,
|
||||
const Standard_Address /*theProgressBarFunc*/,
|
||||
const Standard_Address /*theProgressObject*/)
|
||||
{
|
||||
#ifdef HAVE_GL2PS
|
||||
|
||||
OSD_Localizer locate(LC_NUMERIC,"C");
|
||||
|
||||
Standard_Integer mode = -1;
|
||||
Standard_Integer sortType = Graphic3d_ST_BSP_Tree;
|
||||
switch( Format )
|
||||
Standard_Integer aFormat = -1;
|
||||
Standard_Integer aSortType = Graphic3d_ST_BSP_Tree;
|
||||
switch (theFormat)
|
||||
{
|
||||
case Graphic3d_EF_PostScript:
|
||||
mode = GL2PS_PS;
|
||||
break;
|
||||
case Graphic3d_EF_EnhPostScript:
|
||||
mode = GL2PS_EPS;
|
||||
break;
|
||||
case Graphic3d_EF_TEX:
|
||||
mode = GL2PS_TEX;
|
||||
break;
|
||||
case Graphic3d_EF_PDF:
|
||||
mode = GL2PS_PDF;
|
||||
break;
|
||||
case Graphic3d_EF_SVG:
|
||||
mode = GL2PS_SVG;
|
||||
break;
|
||||
case Graphic3d_EF_PGF:
|
||||
mode = GL2PS_PGF;
|
||||
break;
|
||||
case Graphic3d_EF_PostScript:
|
||||
aFormat = GL2PS_PS;
|
||||
break;
|
||||
case Graphic3d_EF_EnhPostScript:
|
||||
aFormat = GL2PS_EPS;
|
||||
break;
|
||||
case Graphic3d_EF_TEX:
|
||||
aFormat = GL2PS_TEX;
|
||||
break;
|
||||
case Graphic3d_EF_PDF:
|
||||
aFormat = GL2PS_PDF;
|
||||
break;
|
||||
case Graphic3d_EF_SVG:
|
||||
aFormat = GL2PS_SVG;
|
||||
break;
|
||||
case Graphic3d_EF_PGF:
|
||||
aFormat = GL2PS_PGF;
|
||||
break;
|
||||
case Graphic3d_EF_EMF:
|
||||
//aFormat = GL2PS_EMF;
|
||||
aFormat = GL2PS_PGF + 1; // 6
|
||||
break;
|
||||
default:
|
||||
// unsupported format
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
switch( aSortType )
|
||||
switch (theSortType)
|
||||
{
|
||||
case Graphic3d_ST_Simple:
|
||||
sortType = GL2PS_SIMPLE_SORT;
|
||||
break;
|
||||
case Graphic3d_ST_BSP_Tree:
|
||||
sortType = GL2PS_BSP_SORT;
|
||||
break;
|
||||
case Graphic3d_ST_Simple:
|
||||
aSortType = GL2PS_SIMPLE_SORT;
|
||||
break;
|
||||
case Graphic3d_ST_BSP_Tree:
|
||||
aSortType = GL2PS_BSP_SORT;
|
||||
break;
|
||||
}
|
||||
|
||||
GLint viewport[4];
|
||||
viewport[0] = 0;
|
||||
viewport[1] = 0;
|
||||
viewport[2] = W;
|
||||
viewport[3] = H;
|
||||
GLint aViewport[4];
|
||||
aViewport[0] = 0;
|
||||
aViewport[1] = 0;
|
||||
aViewport[2] = theWidth;
|
||||
aViewport[3] = theHeight;
|
||||
|
||||
GLint buffersize = 1024*1024;
|
||||
GLint aBufferSize = 1024 * 1024;
|
||||
GLint anErrCode = GL2PS_SUCCESS;
|
||||
|
||||
while( buffersize>0 )
|
||||
// gl2ps uses standard write functions and do not check locale
|
||||
OSD_Localizer locate (LC_NUMERIC, "C");
|
||||
|
||||
while (aBufferSize > 0)
|
||||
{
|
||||
FILE *file = fopen(FileName,"wb");
|
||||
gl2psBeginPage( "", "", viewport, mode, sortType,
|
||||
// current patch for EMF support in gl2ps uses WinAPI functions to create file
|
||||
FILE* aFileH = (theFormat != Graphic3d_EF_EMF) ? fopen (theFileName, "wb") : NULL;
|
||||
anErrCode = gl2psBeginPage ("", "", aViewport, aFormat, aSortType,
|
||||
GL2PS_DRAW_BACKGROUND | GL2PS_OCCLUSION_CULL | GL2PS_BEST_ROOT/* | GL2PS_SIMPLE_LINE_OFFSET*/,
|
||||
GL_RGBA, 0, NULL,
|
||||
0, 0, 0, buffersize, file, FileName);
|
||||
0, 0, 0, aBufferSize, aFileH, theFileName);
|
||||
if (anErrCode != GL2PS_SUCCESS)
|
||||
{
|
||||
// initialization failed
|
||||
if (aFileH != NULL)
|
||||
fclose (aFileH);
|
||||
break;
|
||||
}
|
||||
Redraw (theView, theLayerUnder, theLayerOver);
|
||||
|
||||
Redraw( View, Under, Over );
|
||||
anErrCode = gl2psEndPage();
|
||||
if (aFileH != NULL)
|
||||
fclose (aFileH);
|
||||
|
||||
GLint num = gl2psEndPage();
|
||||
|
||||
fclose(file);
|
||||
|
||||
if( num==GL2PS_OVERFLOW )
|
||||
buffersize *= 2;
|
||||
else
|
||||
break;
|
||||
if (anErrCode == GL2PS_OVERFLOW)
|
||||
aBufferSize *= 2;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
locate.Restore();
|
||||
|
||||
return anErrCode == GL2PS_SUCCESS;
|
||||
#else
|
||||
return Standard_False;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -1563,35 +1563,79 @@ static int VPan( Draw_Interpretor& di, Standard_Integer argc, const char** argv
|
||||
|
||||
//==============================================================================
|
||||
//function : VExport
|
||||
//purpose : Export teh view to a vector graphic format (PS, EMF, PDF)
|
||||
//purpose : Export the view to a vector graphic format (PS, EMF, PDF)
|
||||
//==============================================================================
|
||||
|
||||
static int VExport(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
{
|
||||
Handle(V3d_View) V3dView = ViewerTest::CurrentView();
|
||||
if ( V3dView.IsNull() ) return 1;
|
||||
if (V3dView.IsNull())
|
||||
return 1;
|
||||
|
||||
if ( argc != 3 ) {
|
||||
di << argv[0] << "Invalid number of arguments" << "\n";
|
||||
if (argc == 1)
|
||||
{
|
||||
std::cout << "Usage: " << argv[0] << " Filename [Format]\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aFormat( argv[2] );
|
||||
aFormat.UpperCase();
|
||||
Graphic3d_ExportFormat exFormat;
|
||||
if ( aFormat == "PS" )
|
||||
exFormat = Graphic3d_EF_PostScript;
|
||||
if ( aFormat == "EPS" )
|
||||
exFormat = Graphic3d_EF_EnhPostScript;
|
||||
if ( aFormat == "TEX" )
|
||||
exFormat = Graphic3d_EF_TEX;
|
||||
if ( aFormat == "PDF" )
|
||||
exFormat = Graphic3d_EF_PDF;
|
||||
if ( aFormat == "SVG" )
|
||||
exFormat = Graphic3d_EF_SVG;
|
||||
if ( aFormat == "PGF" )
|
||||
exFormat = Graphic3d_EF_PGF;
|
||||
V3dView->View()->Export( argv[1], exFormat );
|
||||
Graphic3d_ExportFormat anExpFormat = Graphic3d_EF_PDF;
|
||||
TCollection_AsciiString aFormatStr;
|
||||
|
||||
TCollection_AsciiString aFileName (argv[1]);
|
||||
Standard_Integer aLen = aFileName.Length();
|
||||
|
||||
if (argc > 2)
|
||||
{
|
||||
aFormatStr = TCollection_AsciiString (argv[2]);
|
||||
}
|
||||
else if (aLen >= 4)
|
||||
{
|
||||
if (aFileName.Value (aLen - 2) == '.')
|
||||
{
|
||||
aFormatStr = aFileName.SubString (aLen - 1, aLen);
|
||||
}
|
||||
else if (aFileName.Value (aLen - 3) == '.')
|
||||
{
|
||||
aFormatStr = aFileName.SubString (aLen - 2, aLen);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Export format couln't be detected from filename '" << argv[1] << "'\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Export format couln't be detected from filename '" << argv[1] << "'\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
aFormatStr.UpperCase();
|
||||
if (aFormatStr == "PS")
|
||||
anExpFormat = Graphic3d_EF_PostScript;
|
||||
else if (aFormatStr == "EPS")
|
||||
anExpFormat = Graphic3d_EF_EnhPostScript;
|
||||
else if (aFormatStr == "TEX")
|
||||
anExpFormat = Graphic3d_EF_TEX;
|
||||
else if (aFormatStr == "PDF")
|
||||
anExpFormat = Graphic3d_EF_PDF;
|
||||
else if (aFormatStr == "SVG")
|
||||
anExpFormat = Graphic3d_EF_SVG;
|
||||
else if (aFormatStr == "PGF")
|
||||
anExpFormat = Graphic3d_EF_PGF;
|
||||
else if (aFormatStr == "EMF")
|
||||
anExpFormat = Graphic3d_EF_EMF;
|
||||
else
|
||||
{
|
||||
std::cout << "Invalid export format '" << aFormatStr << "'\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!V3dView->View()->Export (argv[1], anExpFormat))
|
||||
{
|
||||
std::cout << "Export failed!\n";
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1955,7 +1999,9 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
|
||||
"vpan : vpan dx dy",
|
||||
__FILE__,VPan,group);
|
||||
theCommands.Add("vexport",
|
||||
"vexport : vexport full_file_path {PS | EPS | TEX | PDF | SVG | PGV } : exports the view to a vector file of a given format",
|
||||
"vexport : vexport full_file_path {PS | EPS | TEX | PDF | SVG | PGF | EMF }"
|
||||
" : exports the view to a vector file of a given format"
|
||||
" : notice that EMF format requires patched gl2ps",
|
||||
__FILE__,VExport,group);
|
||||
theCommands.Add("vcolorscale",
|
||||
"vcolorscale : vcolorscale [RangeMin = 0 RangeMax = 100 Intervals = 10 HeightFont = 16 Position = 2 X = 0 Y = 0]: draw color scale",
|
||||
|
@ -1230,12 +1230,17 @@ is
|
||||
-- currently used in triedron displaying
|
||||
|
||||
Export( me;
|
||||
FileName : CString from Standard;
|
||||
Format : ExportFormat from Graphic3d;
|
||||
SortType : SortType from Graphic3d = Graphic3d_ST_BSP_Tree;
|
||||
Precision : Real from Standard = 0.005;
|
||||
ProgressBarFunc : Address from Standard = NULL;
|
||||
ProgressObject : Address from Standard = NULL );
|
||||
theFileName : CString from Standard;
|
||||
theFormat : ExportFormat from Graphic3d;
|
||||
theSortType : SortType from Graphic3d = Graphic3d_ST_BSP_Tree;
|
||||
thePrecision : Real from Standard = 0.005;
|
||||
theProgressBarFunc : Address from Standard = NULL;
|
||||
theProgressObject : Address from Standard = NULL )
|
||||
returns Boolean from Standard;
|
||||
---Purpose:
|
||||
-- Export scene into the one of the Vector graphics formats (SVG, PS, PDF...).
|
||||
-- In contrast to Bitmaps, Vector graphics is scalable (so you may got quality benefits on printing to laser printer).
|
||||
-- Notice however that results may differ a lot and do not contain some elements.
|
||||
|
||||
fields
|
||||
|
||||
|
@ -4287,28 +4287,29 @@ Standard_Boolean Visual3d_View::IsGLLightEnabled() const
|
||||
#endif
|
||||
}
|
||||
|
||||
void Visual3d_View::Export( const Standard_CString FileName,
|
||||
const Graphic3d_ExportFormat Format,
|
||||
const Graphic3d_SortType aSortType,
|
||||
const Standard_Real Precision,
|
||||
const Standard_Address ProgressBarFunc,
|
||||
const Standard_Address ProgressObject ) const
|
||||
Standard_Boolean Visual3d_View::Export (const Standard_CString theFileName,
|
||||
const Graphic3d_ExportFormat theFormat,
|
||||
const Graphic3d_SortType theSortType,
|
||||
const Standard_Real thePrecision,
|
||||
const Standard_Address theProgressBarFunc,
|
||||
const Standard_Address theProgressObject) const
|
||||
{
|
||||
Handle( Visual3d_Layer ) AnUnderLayer = MyViewManager->UnderLayer(),
|
||||
AnOverLayer = MyViewManager->OverLayer();
|
||||
Handle(Visual3d_Layer) anUnderLayer = MyViewManager->UnderLayer();
|
||||
Handle(Visual3d_Layer) anOverLayer = MyViewManager->OverLayer();
|
||||
|
||||
Aspect_CLayer2d OverCLayer;
|
||||
Aspect_CLayer2d UnderCLayer;
|
||||
OverCLayer.ptrLayer = UnderCLayer.ptrLayer = NULL;
|
||||
Aspect_CLayer2d anOverCLayer;
|
||||
Aspect_CLayer2d anUnderCLayer;
|
||||
anOverCLayer.ptrLayer = anUnderCLayer.ptrLayer = NULL;
|
||||
|
||||
if( !AnOverLayer.IsNull() )
|
||||
OverCLayer = AnOverLayer->CLayer();
|
||||
if( !AnUnderLayer.IsNull() )
|
||||
UnderCLayer = AnUnderLayer->CLayer();
|
||||
if (!anOverLayer.IsNull())
|
||||
anOverCLayer = anOverLayer->CLayer();
|
||||
if (!anUnderLayer.IsNull())
|
||||
anUnderCLayer = anUnderLayer->CLayer();
|
||||
|
||||
Standard_Integer W, H;
|
||||
Window()->Size( W, H );
|
||||
Standard_Integer aWidth, aHeight;
|
||||
Window()->Size (aWidth, aHeight);
|
||||
|
||||
MyGraphicDriver->Export( FileName, Format, aSortType, W, H, MyCView, UnderCLayer, OverCLayer,
|
||||
Precision, ProgressBarFunc, ProgressObject );
|
||||
return MyGraphicDriver->Export (theFileName, theFormat, theSortType,
|
||||
aWidth, aHeight, MyCView, anUnderCLayer, anOverCLayer,
|
||||
thePrecision, theProgressBarFunc, theProgressObject);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user