Import Geant4 11.1.0.beta source tree
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
# - G4OpenInventor category build
|
||||
|
||||
geant4_global_library_target(COMPONENTS sources.cmake)
|
||||
include(sources.cmake)
|
||||
geant4_add_category(G4OpenInventor MODULES G4OpenInventor)
|
||||
|
||||
@@ -5,7 +5,7 @@ ifndef G4INSTALL
|
||||
G4INSTALL = ../../..
|
||||
endif
|
||||
|
||||
GLOBLIBS = libG4vis_management.lib libG4modeling.lib libG4gl2ps.lib
|
||||
GLOBLIBS = libG4vis_management.lib libG4modeling.lib libG4tools.lib
|
||||
ifdef G4LIB_BUILD_ZLIB
|
||||
GLOBLIBS += libG4zlib.lib
|
||||
endif
|
||||
@@ -20,9 +20,9 @@ include $(G4INSTALL)/config/G4VIS_BUILD.gmk
|
||||
include $(G4INSTALL)/config/G4UI_BUILD.gmk
|
||||
include $(G4INSTALL)/config/interactivity.gmk
|
||||
|
||||
CPPFLAGS += -I$(G4BASE)/visualization/externals/gl2ps/include
|
||||
CPPFLAGS += -I$(G4BASE)/visualization/management/include
|
||||
CPPFLAGS += -I$(G4BASE)/visualization/modeling/include
|
||||
CPPFLAGS += -I$(G4BASE)/externals/g4tools/include
|
||||
CPPFLAGS += -I$(G4BASE)/global/management/include
|
||||
CPPFLAGS += -I$(G4BASE)/global/HEPGeometry/include
|
||||
CPPFLAGS += -I$(G4BASE)/geometry/solids/CSG/include
|
||||
|
||||
@@ -1,23 +1,42 @@
|
||||
-------------------------------------------------------------------
|
||||
# Category openinventor History
|
||||
|
||||
=========================================================
|
||||
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
|
||||
=========================================================
|
||||
See `CONTRIBUTING.rst` for details of **required** info/format for each entry,
|
||||
which **must** added in reverse chronological order (newest at the top). It must **not**
|
||||
be used as a substitute for writing good git commit messages!
|
||||
|
||||
Category History file
|
||||
---------------------
|
||||
This file should be used by G4 developers and category coordinators
|
||||
to briefly summarize all major modifications introduced in the code
|
||||
and keep track of all category-tags.
|
||||
It DOES NOT substitute the CVS log-message one should put at every
|
||||
committal in the CVS repository !
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
----------------------------------------------------------
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
## 2022-05-03 Ben Morgan (openinventor-V11-00-07)
|
||||
- Preliminary build support for Qt5 and Qt6
|
||||
|
||||
## 2022-04-21 Guy Barrand (openinventor-V11-00-06)
|
||||
- Have G4OpenGLOpenInventorViewer and SoGL2PSAction not using visman/G4gl2ps (but still using the thread safe tools/gl2ps).
|
||||
|
||||
## 2022-04-11 Guy Barrand (openinventor-V11-00-05)
|
||||
- Have G4OpenGLOpenInventorViewer and SoGL2PSAction use the thread safe tools/gl2ps.
|
||||
|
||||
## 2022-03-22 Ben Morgan (openinventor-V11-00-04)
|
||||
- Use geant4_module_sources to add optional sources
|
||||
|
||||
## 2022-02-09 Gabriele Cosmo (openinventor-V11-00-03)
|
||||
- `G4OpenInventorQtExaminerViewer`: Fixed compilation warning on Intel
|
||||
compiler for shadowing data.
|
||||
|
||||
## 2022-01-28 Ben Morgan (openinventor-V11-00-02)
|
||||
- Replace `geant4_global_library_target` with direct file inclusion and
|
||||
call to `geant4_add_category` to define library build from source modules.
|
||||
|
||||
## 2021-12-11 John Allison (openinventor-V11-00-01)
|
||||
- `G4OpenInventorViewer`: Remove misleading obsolete comment regarding
|
||||
kernel visit in the case of a change in vis attribute modifiers.
|
||||
|
||||
## 2021-12-10 Ben Morgan (openinventor-V11-00-00)
|
||||
- Change to new Markdown History format
|
||||
|
||||
---
|
||||
|
||||
# History entries prior to 11.0
|
||||
|
||||
History file for visualization/OpenInventor
|
||||
-------------------------------------------
|
||||
12 November 2021 - Ben Morgan (openinventor-V10-07-06)
|
||||
- Retire G4VIS_... preprocessor symbols in toolkit build, only required
|
||||
by obsolete GNUmake system
|
||||
|
||||
@@ -27,27 +27,50 @@
|
||||
#define HEPVis_SoGL2PSAction_h
|
||||
|
||||
#include <Inventor/actions/SoGLRenderAction.h>
|
||||
#include "G4OpenGL2PSAction.hh"
|
||||
|
||||
#include <tools/gl2ps_def.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* SoGL2PSAction inherits Inventor/SoGLRenderAction.
|
||||
* It uses the gl2ps software to produce vector PostScript of a scene graph.
|
||||
* See applications/DetectorTreeKit, Polyhedron for examples.
|
||||
*/
|
||||
|
||||
#define SoGL2PSAction Geant4_SoGL2PSAction
|
||||
|
||||
class SoGL2PSAction : public SoGLRenderAction, public G4OpenGL2PSAction {
|
||||
class SoGL2PSAction : public SoGLRenderAction {
|
||||
SO_ACTION_HEADER(SoGL2PSAction);
|
||||
public:
|
||||
SoGL2PSAction(const SbViewportRegion&);
|
||||
virtual ~SoGL2PSAction();
|
||||
public: /*SoINTERNAL*/
|
||||
static void initClass();
|
||||
public:
|
||||
void setFileName(const std::string&);
|
||||
void setTitleAndProducer(const std::string&,const std::string&);
|
||||
void setExportImageFormat_PS();
|
||||
void setExportImageFormat_EPS();
|
||||
void setExportImageFormat_TEX();
|
||||
void setExportImageFormat_PDF();
|
||||
void setExportImageFormat_SVG();
|
||||
void setExportImageFormat_PGF();
|
||||
bool enableFileWriting();
|
||||
void disableFileWriting();
|
||||
bool addBitmap(int,int,float=0,float=0,float=0,float=0);
|
||||
protected:
|
||||
virtual void beginTraversal(SoNode*);
|
||||
private:
|
||||
bool openFile();
|
||||
void closeFile();
|
||||
bool beginPage(int,int,int,int);
|
||||
bool endPage();
|
||||
tools_GL2PScontextPointer fContext;
|
||||
FILE* fFile;
|
||||
std::string fFileName;
|
||||
std::string fTitle;
|
||||
std::string fProducer;
|
||||
unsigned int fFormat;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,140 +1,37 @@
|
||||
# - G4OpenInventor module build definition
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Geant4 OpenInventor Core sources and headers (all platforms)
|
||||
#
|
||||
set(G4VIS_MODULE_OPENINVENTOR_HEADERS
|
||||
G4OpenInventor.hh
|
||||
G4OpenInventorSceneHandler.hh
|
||||
G4OpenInventorTransform3D.hh
|
||||
G4OpenInventorViewer.hh
|
||||
G4VisFeaturesOfOpenInventor.hh
|
||||
Geant4_SoPolyhedron.h
|
||||
SoG4LineSet.h
|
||||
SoG4MarkerSet.h
|
||||
SoG4Polyhedron.h
|
||||
)
|
||||
|
||||
set(G4VIS_MODULE_OPENINVENTOR_SOURCES
|
||||
G4OpenInventor.cc
|
||||
G4OpenInventorSceneHandler.cc
|
||||
G4OpenInventorTransform3D.cc
|
||||
G4OpenInventorViewer.cc
|
||||
G4VisFeaturesOfOpenInventor.cc
|
||||
SbPainter.cc
|
||||
SbPainterPS.cc
|
||||
SoAlternateRepAction.cc
|
||||
SoBox.cc
|
||||
SoCons.cc
|
||||
SoCounterAction.cc
|
||||
SoDetectorTreeKit.cc
|
||||
SoGL2PSAction.cc
|
||||
SoImageWriter.cc
|
||||
SoMarkerSet.cc
|
||||
SoPolyhedron.cc
|
||||
SoStyleCache.cc
|
||||
SoTrap.cc
|
||||
SoTrd.cc
|
||||
SoTubs.cc
|
||||
)
|
||||
|
||||
set(G4VIS_MODULE_OPENINVENTOR_LINK_LIBRARIES Coin::Coin)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# UNIX Only (Xt) sources
|
||||
#
|
||||
if(GEANT4_USE_INVENTOR_XT)
|
||||
list(APPEND G4VIS_MODULE_OPENINVENTOR_HEADERS
|
||||
G4OpenInventorX.hh
|
||||
G4OpenInventorXt.hh
|
||||
G4OpenInventorXtExaminerViewerMessenger.hh
|
||||
G4OpenInventorXtExaminerViewer.hh
|
||||
G4OpenInventorXtExtended.hh
|
||||
G4OpenInventorXtExtendedViewer.hh
|
||||
G4OpenInventorXtViewer.hh
|
||||
wheelmouse.h
|
||||
SoXtInternal.h
|
||||
console.h
|
||||
favorites.h
|
||||
saveViewPt.h
|
||||
pickext.h
|
||||
pickref.h
|
||||
wireframe.h)
|
||||
|
||||
list(APPEND G4VIS_MODULE_OPENINVENTOR_SOURCES
|
||||
G4OpenInventorXt.cc
|
||||
G4OpenInventorXtExaminerViewer.cc
|
||||
G4OpenInventorXtExaminerViewerMessenger.cc
|
||||
G4OpenInventorXtExtended.cc
|
||||
G4OpenInventorXtExtendedViewer.cc
|
||||
G4OpenInventorXtViewer.cc
|
||||
wheelmouse.cc)
|
||||
|
||||
# Add the definitions for SoXt
|
||||
add_definitions(-DG4VIS_BUILD_OIX_DRIVER)
|
||||
|
||||
# SoXt Library and others
|
||||
list(APPEND G4VIS_MODULE_OPENINVENTOR_LINK_LIBRARIES SoXt::SoXt Motif::Xm)
|
||||
if(APPLE)
|
||||
list(APPEND G4VIS_MODULE_OPENINVENTOR_LINK_LIBRARIES XQuartzGL::GL)
|
||||
else()
|
||||
list(APPEND G4VIS_MODULE_OPENINVENTOR_LINK_LIBRARIES OpenGL::GL)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Open Inventor Qt
|
||||
#
|
||||
if(GEANT4_USE_INVENTOR_QT)
|
||||
list(APPEND G4VIS_MODULE_OPENINVENTOR_HEADERS
|
||||
G4OpenInventorQt.hh
|
||||
G4OpenInventorQtExaminerViewer.hh
|
||||
G4OpenInventorQtViewer.hh
|
||||
G4SoQt.hh
|
||||
ui_OIQtListsDialog.h)
|
||||
|
||||
list(APPEND G4VIS_MODULE_OPENINVENTOR_SOURCES
|
||||
G4OpenInventorQt.cc
|
||||
G4OpenInventorQtExaminerViewer.cc
|
||||
G4OpenInventorQtViewer.cc
|
||||
G4SoQt.cc)
|
||||
|
||||
# Add libraries
|
||||
list(APPEND G4VIS_MODULE_OPENINVENTOR_LINK_LIBRARIES
|
||||
SoQt::SoQt
|
||||
OpenGL::GL
|
||||
Qt5::OpenGL Qt5::Gui Qt5::PrintSupport Qt5::Widgets)
|
||||
endif()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# WIN32 Only (Win32) sources
|
||||
#
|
||||
if(GEANT4_USE_INVENTOR_WIN)
|
||||
set(G4VIS_MODULE_OPENINVENTOR_HEADERS
|
||||
${G4VIS_MODULE_OPENINVENTOR_HEADERS}
|
||||
G4OpenInventorWin.hh
|
||||
G4OpenInventorWin32.hh
|
||||
G4OpenInventorWinViewer.hh
|
||||
)
|
||||
|
||||
set(G4VIS_MODULE_OPENINVENTOR_SOURCES
|
||||
${G4VIS_MODULE_OPENINVENTOR_SOURCES}
|
||||
G4OpenInventorWin.cc
|
||||
G4OpenInventorWinViewer.cc
|
||||
)
|
||||
|
||||
# SoWin Library
|
||||
list(APPEND G4VIS_MODULE_OPENINVENTOR_LINK_LIBRARIES SoWin::SoWin OpenGL::GL)
|
||||
endif()
|
||||
|
||||
|
||||
# Define the Geant4 Module.
|
||||
geant4_add_module(G4OpenInventor
|
||||
PUBLIC_HEADERS
|
||||
${G4VIS_MODULE_OPENINVENTOR_HEADERS}
|
||||
G4OpenInventor.hh
|
||||
G4OpenInventorSceneHandler.hh
|
||||
G4OpenInventorTransform3D.hh
|
||||
G4OpenInventorViewer.hh
|
||||
G4VisFeaturesOfOpenInventor.hh
|
||||
Geant4_SoPolyhedron.h
|
||||
SoG4LineSet.h
|
||||
SoG4MarkerSet.h
|
||||
SoG4Polyhedron.h
|
||||
SOURCES
|
||||
${G4VIS_MODULE_OPENINVENTOR_SOURCES})
|
||||
G4OpenInventor.cc
|
||||
G4OpenInventorSceneHandler.cc
|
||||
G4OpenInventorTransform3D.cc
|
||||
G4OpenInventorViewer.cc
|
||||
G4VisFeaturesOfOpenInventor.cc
|
||||
SbPainter.cc
|
||||
SbPainterPS.cc
|
||||
SoAlternateRepAction.cc
|
||||
SoBox.cc
|
||||
SoCons.cc
|
||||
SoCounterAction.cc
|
||||
SoDetectorTreeKit.cc
|
||||
SoGL2PSAction.cc
|
||||
SoImageWriter.cc
|
||||
SoMarkerSet.cc
|
||||
SoPolyhedron.cc
|
||||
SoStyleCache.cc
|
||||
SoTrap.cc
|
||||
SoTrd.cc
|
||||
SoTubs.cc )
|
||||
|
||||
geant4_module_link_libraries(G4OpenInventor
|
||||
PUBLIC
|
||||
@@ -145,11 +42,80 @@ geant4_module_link_libraries(G4OpenInventor
|
||||
G4intercoms
|
||||
G4modeling
|
||||
G4vis_management
|
||||
${G4VIS_MODULE_OPENINVENTOR_LINK_LIBRARIES}
|
||||
Coin::Coin
|
||||
PRIVATE
|
||||
G4UIbasic
|
||||
G4csg
|
||||
G4geometrymng
|
||||
G4gl2ps
|
||||
G4tools
|
||||
G4materials
|
||||
G4tracking)
|
||||
G4tracking)
|
||||
|
||||
# UNIX Only (Xt) sources
|
||||
if(GEANT4_USE_INVENTOR_XT)
|
||||
geant4_module_sources(G4OpenInventor
|
||||
PUBLIC_HEADERS
|
||||
G4OpenInventorX.hh
|
||||
G4OpenInventorXt.hh
|
||||
G4OpenInventorXtExaminerViewerMessenger.hh
|
||||
G4OpenInventorXtExaminerViewer.hh
|
||||
G4OpenInventorXtExtended.hh
|
||||
G4OpenInventorXtExtendedViewer.hh
|
||||
G4OpenInventorXtViewer.hh
|
||||
wheelmouse.h
|
||||
SoXtInternal.h
|
||||
console.h
|
||||
favorites.h
|
||||
saveViewPt.h
|
||||
pickext.h
|
||||
pickref.h
|
||||
wireframe.h
|
||||
SOURCES
|
||||
G4OpenInventorXt.cc
|
||||
G4OpenInventorXtExaminerViewer.cc
|
||||
G4OpenInventorXtExaminerViewerMessenger.cc
|
||||
G4OpenInventorXtExtended.cc
|
||||
G4OpenInventorXtExtendedViewer.cc
|
||||
G4OpenInventorXtViewer.cc
|
||||
wheelmouse.cc )
|
||||
|
||||
geant4_module_compile_definitions(G4OpenInventor PRIVATE G4VIS_BUILD_OIX_DRIVER)
|
||||
geant4_module_link_libraries(G4OpenInventor PUBLIC SoXt::SoXt Motif::Xm)
|
||||
if(APPLE)
|
||||
geant4_module_link_libraries(G4OpenInventor PUBLIC XQuartzGL::GL)
|
||||
else()
|
||||
geant4_module_link_libraries(G4OpenInventor PUBLIC OpenGL::GL)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Qt-only sources
|
||||
if(GEANT4_USE_INVENTOR_QT)
|
||||
geant4_module_sources(G4OpenInventor
|
||||
PUBLIC_HEADERS
|
||||
G4OpenInventorQt.hh
|
||||
G4OpenInventorQtExaminerViewer.hh
|
||||
G4OpenInventorQtViewer.hh
|
||||
G4SoQt.hh
|
||||
ui_OIQtListsDialog.h
|
||||
SOURCES
|
||||
G4OpenInventorQt.cc
|
||||
G4OpenInventorQtExaminerViewer.cc
|
||||
G4OpenInventorQtViewer.cc
|
||||
G4SoQt.cc )
|
||||
|
||||
geant4_module_link_libraries(G4OpenInventor PUBLIC SoQt::SoQt OpenGL::GL Qt${QT_VERSION_MAJOR}::OpenGL Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::PrintSupport Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
endif()
|
||||
|
||||
# - WIN32 Only (Win32) sources
|
||||
if(GEANT4_USE_INVENTOR_WIN)
|
||||
geant4_module_sources(G4OpenInventor
|
||||
PUBLIC_HEADERS
|
||||
G4OpenInventorWin.hh
|
||||
G4OpenInventorWin32.hh
|
||||
G4OpenInventorWinViewer.hh
|
||||
SOURCES
|
||||
G4OpenInventorWin.cc
|
||||
G4OpenInventorWinViewer.cc)
|
||||
|
||||
geant4_module_link_libraries(G4OpenInventor PUBLIC SoWin::SoWin OpenGL::GL)
|
||||
endif()
|
||||
|
||||
@@ -1292,8 +1292,8 @@ void G4OpenInventorQtExaminerViewer::mouseoverCB(void *aThis, SoEventCallback *e
|
||||
SoGetBoundingBoxAction bAction(viewportRegion);
|
||||
bAction.apply((SoFullPath*)path);
|
||||
SbBox3f bBox = bAction.getBoundingBox();
|
||||
SbVec3f center = bBox.getCenter();
|
||||
center.getValue(x,y,z);
|
||||
SbVec3f centr = bBox.getCenter();
|
||||
centr.getValue(x,y,z);
|
||||
ssZPos << "Pos: " << x << " " << y << " " << z;
|
||||
|
||||
G4AttHolder* attHolder = dynamic_cast<G4AttHolder*>(node);
|
||||
|
||||
@@ -189,11 +189,8 @@ G4bool G4OpenInventorViewer::CompareForKernelVisit(G4ViewParameters& vp) {
|
||||
// needs a kernel visit. (In this respect, it differs from the
|
||||
// OpenGL drivers, where it's done in SetView.)
|
||||
(vp.GetScaleFactor () != fVP.GetScaleFactor ()) ||
|
||||
// If G4OpenInventor ever introduces VAMs, the following might need
|
||||
// changing to a complete comparison, i.e., remove ".size()". See
|
||||
// G4OpenGLStoredViewer::CompareForKernelVisit.
|
||||
(vp.GetVisAttributesModifiers() !=
|
||||
fVP.GetVisAttributesModifiers()) ||
|
||||
fVP.GetVisAttributesModifiers()) ||
|
||||
(vp.IsSpecialMeshRendering() !=
|
||||
fVP.IsSpecialMeshRendering())
|
||||
)
|
||||
@@ -525,29 +522,25 @@ void G4OpenInventorViewer::Escape(){
|
||||
void G4OpenInventorViewer::WritePostScript(const G4String& aFile) {
|
||||
if(!fGL2PSAction) return;
|
||||
fGL2PSAction->setFileName(aFile.c_str());
|
||||
fGL2PSAction->setExportImageFormat(GL2PS_EPS);
|
||||
// Use gl2ps default buffer (2048*2048)
|
||||
fGL2PSAction->setBufferSize(0);
|
||||
fGL2PSAction->setExportImageFormat_EPS();
|
||||
fGL2PSAction->setTitleAndProducer("Geant4 output","Geant4");
|
||||
G4cout << "Produce " << aFile << "..." << G4endl;
|
||||
if (fGL2PSAction->enableFileWriting()) {
|
||||
ViewerRender();
|
||||
fGL2PSAction->disableFileWriting();
|
||||
}
|
||||
fGL2PSAction->resetBufferSizeParameters();
|
||||
}
|
||||
|
||||
void G4OpenInventorViewer::WritePDF(const G4String& aFile) {
|
||||
if(!fGL2PSAction) return;
|
||||
fGL2PSAction->setFileName(aFile.c_str());
|
||||
fGL2PSAction->setExportImageFormat(GL2PS_PDF);
|
||||
// Use gl2ps default buffer (2048*2048)
|
||||
fGL2PSAction->setBufferSize(0);
|
||||
fGL2PSAction->setExportImageFormat_PDF();
|
||||
fGL2PSAction->setTitleAndProducer("Geant4 output","Geant4");
|
||||
G4cout << "Produce " << aFile << "..." << G4endl;
|
||||
if (fGL2PSAction->enableFileWriting()) {
|
||||
ViewerRender();
|
||||
fGL2PSAction->disableFileWriting();
|
||||
}
|
||||
fGL2PSAction->resetBufferSizeParameters();
|
||||
}
|
||||
|
||||
void G4OpenInventorViewer::WritePixmapPostScript(const G4String& aFile) {
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <Inventor/elements/SoViewportRegionElement.h>
|
||||
#include <Inventor/errors/SoDebugError.h>
|
||||
|
||||
#include "Geant4_gl2ps.h"
|
||||
#include <Inventor/system/gl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -60,30 +60,71 @@ SoGL2PSAction::SoGL2PSAction(
|
||||
const SbViewportRegion& aViewPortRegion
|
||||
)
|
||||
:SoGLRenderAction(aViewPortRegion)
|
||||
,G4OpenGL2PSAction()
|
||||
,fContext(0)
|
||||
,fFile(0)
|
||||
,fFileName("out.pdf")
|
||||
,fTitle("title")
|
||||
,fProducer("HEPVis::SoGL2PSAction")
|
||||
,fFormat(TOOLS_GL2PS_PDF)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
||||
{
|
||||
setFileName("out.ps");
|
||||
SO_ACTION_CONSTRUCTOR(SoGL2PSAction);
|
||||
}
|
||||
|
||||
bool SoGL2PSAction::enableFileWriting(
|
||||
)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
SoGL2PSAction::~SoGL2PSAction()
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
||||
{
|
||||
fFile = ::fopen(fFileName,"w");
|
||||
if(!fFile) {
|
||||
closeFile();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void SoGL2PSAction::setFileName(const std::string& aFileName)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
||||
{
|
||||
fFileName = aFileName;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void SoGL2PSAction::setTitleAndProducer(const std::string& aTitle,const std::string& aProducer)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
||||
{
|
||||
fTitle = aTitle;
|
||||
fProducer = aProducer;
|
||||
}
|
||||
|
||||
void SoGL2PSAction::setExportImageFormat_PS() {fFormat = TOOLS_GL2PS_PS;}
|
||||
void SoGL2PSAction::setExportImageFormat_EPS() {fFormat = TOOLS_GL2PS_EPS;}
|
||||
void SoGL2PSAction::setExportImageFormat_TEX() {fFormat = TOOLS_GL2PS_TEX;}
|
||||
void SoGL2PSAction::setExportImageFormat_PDF() {fFormat = TOOLS_GL2PS_PDF;}
|
||||
void SoGL2PSAction::setExportImageFormat_SVG() {fFormat = TOOLS_GL2PS_SVG;}
|
||||
void SoGL2PSAction::setExportImageFormat_PGF() {fFormat = TOOLS_GL2PS_PGF;}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
bool SoGL2PSAction::enableFileWriting()
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
||||
{
|
||||
if(!openFile()) {
|
||||
SoDebugError::post("SoGL2PSAction::enableFileWriting",
|
||||
"Cannot open file %s",fFileName.c_str());
|
||||
"openFile() failed for fil %s",
|
||||
fFileName.c_str());
|
||||
return false;
|
||||
}
|
||||
#ifdef __COIN__
|
||||
#else //SGI
|
||||
const SbViewportRegion& vpr = getViewportRegion();
|
||||
SoViewportRegionElement::set(getState(),vpr);
|
||||
G4gl2psBegin();
|
||||
SbVec2s origin = vpr.getViewportOriginPixels();
|
||||
SbVec2s size = vpr.getViewportSizePixels();
|
||||
if(!beginPage(origin[0],origin[1],size[0],size[1])) {
|
||||
SoDebugError::post("SoGL2PSAction::enableFileWriting","beginPage() failed");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
@@ -95,10 +136,146 @@ void SoGL2PSAction::disableFileWriting(
|
||||
{
|
||||
#ifdef __COIN__
|
||||
#else //SGI
|
||||
gl2psEndPage();
|
||||
endPage();
|
||||
#endif
|
||||
::fclose(fFile);
|
||||
fFile = 0;
|
||||
closeFile();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void SoGL2PSAction::beginTraversal(
|
||||
SoNode* aNode
|
||||
)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
||||
{
|
||||
if(fContext && fFile) {
|
||||
#ifdef __COIN__
|
||||
const SbViewportRegion& vpr = getViewportRegion();
|
||||
SoViewportRegionElement::set(getState(),vpr);
|
||||
SbVec2s origin = vpr.getViewportOriginPixels();
|
||||
SbVec2s size = vpr.getViewportSizePixels();
|
||||
if(!beginPage(origin[0],origin[1],size[0],size[1])) {
|
||||
SoDebugError::post("SoGL2PSAction::beginTraversal","beginPage() failed");
|
||||
return;
|
||||
}
|
||||
traverse(aNode);
|
||||
if(!endPage()) {
|
||||
SoDebugError::post("SoGL2PSAction::beginTraversal","endPage() failed");
|
||||
return;
|
||||
}
|
||||
#else //SGI
|
||||
SoGLRenderAction::beginTraversal(aNode);
|
||||
#endif
|
||||
} else {
|
||||
SoGLRenderAction::beginTraversal(aNode);
|
||||
}
|
||||
}
|
||||
|
||||
#include <tools/gl2ps>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
bool SoGL2PSAction::openFile()
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
||||
{
|
||||
if(fFile) {
|
||||
::fclose(fFile);
|
||||
fFile = 0;
|
||||
}
|
||||
if(fContext) {
|
||||
::tools_gl2psDeleteContext(fContext);
|
||||
fContext = 0;
|
||||
}
|
||||
|
||||
fContext = ::tools_gl2psCreateContext();
|
||||
if(!fContext) return false;
|
||||
|
||||
tools_gl2ps_gl_funcs_t _funcs = {
|
||||
(tools_glIsEnabled_func)glIsEnabled,
|
||||
(tools_glBegin_func)glBegin,
|
||||
(tools_glEnd_func)glEnd,
|
||||
(tools_glGetFloatv_func)glGetFloatv,
|
||||
(tools_glVertex3f_func)glVertex3f,
|
||||
(tools_glGetBooleanv_func)glGetBooleanv,
|
||||
(tools_glGetIntegerv_func)glGetIntegerv,
|
||||
(tools_glRenderMode_func)glRenderMode,
|
||||
(tools_glFeedbackBuffer_func)glFeedbackBuffer,
|
||||
(tools_glPassThrough_func)glPassThrough
|
||||
};
|
||||
::tools_gl2ps_set_gl_funcs(fContext,&_funcs);
|
||||
|
||||
fFile = ::fopen(fFileName.c_str(),"wb");
|
||||
if(!fFile) {
|
||||
::tools_gl2psDeleteContext(fContext);
|
||||
fContext = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void SoGL2PSAction::closeFile()
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
||||
{
|
||||
if(fFile) {
|
||||
::fclose(fFile);
|
||||
fFile = 0;
|
||||
}
|
||||
if(fContext) {
|
||||
::tools_gl2psDeleteContext(fContext);
|
||||
fContext = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
bool SoGL2PSAction::beginPage(int a_x,int a_y,int a_w,int a_h)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
||||
{
|
||||
if(!fContext) return false;
|
||||
if(!fFile) return false;
|
||||
|
||||
if( (a_w<=0) || (a_h<=0) ) return false;
|
||||
|
||||
int options =
|
||||
TOOLS_GL2PS_BEST_ROOT |
|
||||
TOOLS_GL2PS_DRAW_BACKGROUND |
|
||||
TOOLS_GL2PS_USE_CURRENT_VIEWPORT;
|
||||
int sort = TOOLS_GL2PS_BSP_SORT;
|
||||
|
||||
int vp[4];
|
||||
vp[0] = a_x;
|
||||
vp[1] = a_y;
|
||||
vp[2] = a_w;
|
||||
vp[3] = a_h;
|
||||
|
||||
int bufferSize = 0;
|
||||
|
||||
tools_GLint res = ::tools_gl2psBeginPage
|
||||
(fContext,fTitle.c_str(),fProducer.c_str(),
|
||||
vp,fFormat,sort,options,TOOLS_GL_RGBA,0, NULL,0,0,0,
|
||||
bufferSize,fFile,fFileName.c_str());
|
||||
if (res == TOOLS_GL2PS_ERROR) return false;
|
||||
|
||||
// enable blending for all
|
||||
::tools_gl2psEnable(fContext,TOOLS_GL2PS_BLEND);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
bool SoGL2PSAction::endPage()
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
||||
{
|
||||
int _status = 0;
|
||||
if(fContext) {
|
||||
_status = ::tools_gl2psEndPage(fContext);
|
||||
}
|
||||
if (_status == TOOLS_GL2PS_OVERFLOW) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -113,19 +290,19 @@ bool SoGL2PSAction::addBitmap(
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
||||
{
|
||||
if(!fFile) return false;
|
||||
if(!fContext) return false;
|
||||
GLboolean valid;
|
||||
glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID,&valid);
|
||||
::glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID,&valid);
|
||||
if(!valid) return false;
|
||||
float pos[4];
|
||||
glGetFloatv(GL_CURRENT_RASTER_POSITION,pos);
|
||||
::glGetFloatv(GL_CURRENT_RASTER_POSITION,pos);
|
||||
int xoff = -(int)(aXmove + aXorig);
|
||||
int yoff = -(int)(aYmove + aYorig);
|
||||
int x = (int)(pos[0] + xoff);
|
||||
int y = (int)(pos[1] + yoff);
|
||||
// Should clip against viewport area :
|
||||
GLint vp[4];
|
||||
glGetIntegerv(GL_VIEWPORT,vp);
|
||||
::glGetIntegerv(GL_VIEWPORT,vp);
|
||||
GLsizei w = aWidth;
|
||||
GLsizei h = aHeight;
|
||||
if(x+w>(vp[0]+vp[2])) w = vp[0]+vp[2]-x;
|
||||
@@ -134,31 +311,9 @@ bool SoGL2PSAction::addBitmap(
|
||||
if(s<=0) return false;
|
||||
float* image = (float*)::malloc(s * sizeof(float));
|
||||
if(!image) return false;
|
||||
glReadPixels(x,y,w,h,GL_RGB,GL_FLOAT,image);
|
||||
GLint status = gl2psDrawPixels(w,h,xoff,yoff,GL_RGB,GL_FLOAT,image);
|
||||
::glReadPixels(x,y,w,h,GL_RGB,GL_FLOAT,image);
|
||||
GLint status = ::tools_gl2psDrawPixels(fContext,w,h,xoff,yoff,GL_RGB,GL_FLOAT,image);
|
||||
::free(image);
|
||||
return (status!=GL2PS_SUCCESS ? false : true);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void SoGL2PSAction::beginTraversal(
|
||||
SoNode* aNode
|
||||
)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
||||
{
|
||||
if(fFile) {
|
||||
#ifdef __COIN__
|
||||
const SbViewportRegion& vpr = getViewportRegion();
|
||||
SoViewportRegionElement::set(getState(),vpr);
|
||||
G4gl2psBegin();
|
||||
traverse(aNode);
|
||||
gl2psEndPage();
|
||||
#else //SGI
|
||||
// Should have already do G4gl2psBegin() before
|
||||
SoGLRenderAction::beginTraversal(aNode);
|
||||
// Should do gl2psEndPage() after
|
||||
#endif
|
||||
} else {
|
||||
SoGLRenderAction::beginTraversal(aNode);
|
||||
}
|
||||
return (status!=TOOLS_GL2PS_SUCCESS ? false : true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user