Import Geant4 11.2.0 source tree
This commit is contained in:
+7
-19
@@ -23,28 +23,16 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef G4VTKCLIPPERCLOSEDPIPELINE_HH
|
||||
#define G4VTKCLIPPERCLOSEDPIPELINE_HH
|
||||
#pragma once
|
||||
|
||||
#include "G4VtkClipClosedSurfacePipeline.hh"
|
||||
#include "G4VGraphicsSystem.hh"
|
||||
|
||||
class vtkAppendPolyData;
|
||||
|
||||
class G4VtkClipperClosedPipeline : public G4VtkPipeline
|
||||
class G4VtkOffscreen : public G4VGraphicsSystem
|
||||
{
|
||||
public:
|
||||
G4VtkClipperClosedPipeline(vtkSmartPointer<vtkPolyDataAlgorithm> filter);
|
||||
~G4VtkClipperClosedPipeline() override = default;
|
||||
|
||||
void Print(){};
|
||||
void Modified();
|
||||
void Clear(){};
|
||||
|
||||
private:
|
||||
vtkSmartPointer<vtkPlane> plane;
|
||||
vtkSmartPointer<vtkClipPolyData> clipper;
|
||||
vtkSmartPointer<vtkAppendPolyData> appendFilter;
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper;
|
||||
G4VtkOffscreen();
|
||||
~G4VtkOffscreen() override = default;
|
||||
G4VSceneHandler* CreateSceneHandler(const G4String& name = "") override;
|
||||
G4VViewer* CreateViewer(G4VSceneHandler&, const G4String& name = "") override;
|
||||
};
|
||||
|
||||
#endif // G4VTKCLIPPERCLOSEDPIPELINE_HH
|
||||
@@ -49,14 +49,14 @@ inline void hash_combine(std::size_t& seed, const T& v, Rest... rest)
|
||||
template<>
|
||||
struct hash<G4String>
|
||||
{
|
||||
std::size_t operator()(const G4String& string) const
|
||||
std::size_t operator()(const G4String& strng) const
|
||||
{
|
||||
using std::hash;
|
||||
using std::size_t;
|
||||
|
||||
std::size_t h = 0;
|
||||
|
||||
for (char const& c : string) {
|
||||
for (char const& c : strng) {
|
||||
std::hash_combine(h, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class G4VtkClipOpenPipeline : public G4VVtkPipeline
|
||||
vtkSmartPointer<vtkPolyDataAlgorithm> filter, G4bool useVcColour = false);
|
||||
~G4VtkClipOpenPipeline() override = default;
|
||||
|
||||
void SetPlane(G4Plane3D& plane);
|
||||
void SetPlane(const G4Plane3D& plane);
|
||||
void SetPlane(G4double x, G4double y, G4double z, G4double nx, G4double ny, G4double nz);
|
||||
void TransformPlane(G4double dx, G4double dy, G4double dz, G4double r00, G4double r01,
|
||||
G4double r02, G4double r10, G4double r11, G4double r12, G4double r20,
|
||||
|
||||
@@ -29,33 +29,46 @@
|
||||
#ifndef G4VTKINTERACTORSTYLE_HH
|
||||
#define G4VTKINTERACTORSTYLE_HH
|
||||
|
||||
#include "G4ios.hh"
|
||||
#include "vtkInteractionStyleModule.h" // For export macro
|
||||
#include "vtkInteractorStyleTrackballCamera.h"
|
||||
#include "vtkInteractorStyleMultiTouchCamera.h"
|
||||
#include <vtkObjectFactory.h>
|
||||
|
||||
// Define interaction style
|
||||
class VTKINTERACTIONSTYLE_EXPORT G4VtkInteractorStyle : public vtkInteractorStyleTrackballCamera
|
||||
class VTKINTERACTIONSTYLE_EXPORT G4VtkInteractorStyle : public vtkInteractorStyleMultiTouchCamera
|
||||
{
|
||||
public:
|
||||
static G4VtkInteractorStyle* New();
|
||||
vtkTypeMacro(G4VtkInteractorStyle, vtkInteractorStyleTrackballCamera)
|
||||
vtkTypeMacro(G4VtkInteractorStyle, vtkInteractorStyleMultiTouchCamera)
|
||||
|
||||
void OnLeftButtonDown() override
|
||||
void OnMouseMove() override
|
||||
{
|
||||
vtkInteractorStyleMultiTouchCamera::OnMouseMove();
|
||||
}
|
||||
|
||||
void OnLeftButtonDown() override
|
||||
{
|
||||
// Forward events
|
||||
vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
|
||||
vtkInteractorStyleMultiTouchCamera::OnLeftButtonDown();
|
||||
}
|
||||
|
||||
|
||||
void OnLeftButtonUp() override
|
||||
{
|
||||
// Forward events
|
||||
vtkInteractorStyleMultiTouchCamera::OnLeftButtonUp();
|
||||
}
|
||||
|
||||
void OnMiddleButtonDown() override
|
||||
{
|
||||
// Forward events
|
||||
vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
|
||||
vtkInteractorStyleMultiTouchCamera::OnMiddleButtonDown();
|
||||
}
|
||||
|
||||
void OnRightButtonDown() override
|
||||
{
|
||||
// Forward events
|
||||
vtkInteractorStyleTrackballCamera::OnRightButtonDown();
|
||||
vtkInteractorStyleMultiTouchCamera::OnRightButtonDown();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -54,17 +54,20 @@ class G4VtkMessenger : public G4UImessenger
|
||||
G4UIcommand* fpCommandExport;
|
||||
G4UIcommand* fpCommandExportCutter;
|
||||
G4UIcommand* fpCommandDebugPrint;
|
||||
G4UIcommand* fpCommandInteractorStart;
|
||||
|
||||
G4UIdirectory* fpDirectorySet;
|
||||
G4UIcommand* fpCommandPolyhedronPipeline;
|
||||
G4UIcmdWithABool* fpCommandWarnings;
|
||||
G4UIcmdWithABool* fpCommandHUD;
|
||||
G4UIcmdWithABool* fpCameraOrientation;
|
||||
G4UIcommand* fpCommandClipper;
|
||||
G4UIcommand* fpCommandCutter;
|
||||
G4UIcommand* fpCommandShadow;
|
||||
|
||||
G4UIdirectory* fpDirectoryAdd;
|
||||
G4UIcommand* fpCommandImageOverlay;
|
||||
G4UIcommand* fpCommandGeometryOverlay;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "G4VViewer.hh"
|
||||
#include "G4VtkViewer.hh"
|
||||
|
||||
class G4VtkOffscreenViewer : public G4VtkViewer
|
||||
{
|
||||
public:
|
||||
G4VtkOffscreenViewer(G4VSceneHandler&, const G4String& name);
|
||||
~G4VtkOffscreenViewer() override;
|
||||
void Initialise() override;
|
||||
|
||||
void FinishView() override;
|
||||
};
|
||||
@@ -42,6 +42,7 @@ class G4VtkPolydataInstanceAppendPipeline : public G4VtkPolydataInstancePipeline
|
||||
|
||||
void Print() override;
|
||||
|
||||
using G4VtkPolydataInstancePipeline::addInstance;
|
||||
void addInstance(G4double dx, G4double dy, G4double dz, G4double r00, G4double r01,
|
||||
G4double r02, G4double r10, G4double r11, G4double r12, G4double r20,
|
||||
G4double r21, G4double r22, G4double r, G4double g, G4double b, G4double a,
|
||||
|
||||
@@ -39,7 +39,9 @@ class G4VtkPolydataInstanceBakePipeline : public G4VtkPolydataInstancePipeline
|
||||
|
||||
void Print() override;
|
||||
|
||||
using G4VtkPolydataInstancePipeline::SetPolydata;
|
||||
void SetPolydata(const G4Polyhedron& polyhedron) override;
|
||||
using G4VtkPolydataInstancePipeline::addInstance;
|
||||
void addInstance(G4double dx, G4double dy, G4double dz, G4double r00, G4double r01,
|
||||
G4double r02, G4double r10, G4double r11, G4double r12, G4double r20,
|
||||
G4double r21, G4double r22, G4double r, G4double g, G4double b, G4double a,
|
||||
|
||||
@@ -40,6 +40,7 @@ class G4VtkPolydataInstanceTensorPipeline : public G4VtkPolydataInstancePipeline
|
||||
|
||||
void Print() override;
|
||||
|
||||
|
||||
static std::size_t MakeHash(const G4Polyhedron& p, const G4VtkVisContext& vc);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -67,6 +67,7 @@ class G4VtkPolydataPipeline : public G4VVtkPipeline
|
||||
|
||||
virtual void SetPolydata(const G4Polyhedron& polyhedron);
|
||||
virtual void SetPolydata(const G4Polyline& polyline);
|
||||
virtual void SetPolydata(vtkPolyData *polydata);
|
||||
virtual void SetPolydataData(const G4Point3D& p);
|
||||
virtual void SetPolydataData(double x, double y, double z);
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ class G4VtkPolydataPolygonPipeline : public G4VtkPolydataPipeline
|
||||
static std::size_t MakeHash(const G4VisAttributes* va);
|
||||
|
||||
protected:
|
||||
G4VisAttributes* pVisAttributes;
|
||||
};
|
||||
|
||||
#endif // GEANT4_G4POLYDATAPOLYGONPIPELINE_HH
|
||||
|
||||
@@ -44,6 +44,7 @@ class G4VtkPolydataPolyline2DPipeline : public G4VtkPolydataPipeline
|
||||
~G4VtkPolydataPolyline2DPipeline() override = default;
|
||||
|
||||
void Modified() override;
|
||||
using G4VtkPolydataPipeline::SetPolydata;
|
||||
void SetPolydata(const G4Polyline& polyline) override;
|
||||
|
||||
vtkSmartPointer<vtkActor2D> GetActor2D() { return actor2D; }
|
||||
@@ -53,7 +54,6 @@ class G4VtkPolydataPolyline2DPipeline : public G4VtkPolydataPipeline
|
||||
static std::size_t MakeHash(const G4VisAttributes* va);
|
||||
|
||||
protected:
|
||||
G4VisAttributes* pVisAttributes;
|
||||
vtkSmartPointer<vtkPolyDataMapper2D> mapper2D;
|
||||
vtkSmartPointer<vtkActor2D> actor2D;
|
||||
};
|
||||
|
||||
@@ -44,7 +44,6 @@ class G4VtkPolydataPolylinePipeline : public G4VtkPolydataPipeline
|
||||
static std::size_t MakeHash(const G4VisAttributes* va);
|
||||
|
||||
protected:
|
||||
G4VisAttributes* pVisAttributes;
|
||||
};
|
||||
|
||||
#endif // G4VTKPOLYDATAPOLYLINEPIPELINE_HH
|
||||
|
||||
@@ -44,7 +44,6 @@ class G4VtkPolydataSpherePipeline : public G4VtkPolydataPipeline
|
||||
static std::size_t MakeHash(const G4VisAttributes* va);
|
||||
|
||||
protected:
|
||||
G4VisAttributes* pVisAttributes;
|
||||
};
|
||||
|
||||
#endif // G4VTKPOLYDATASPHEREPIPELINE_HH
|
||||
|
||||
@@ -41,6 +41,7 @@ class G4VtkQtSceneHandler : public G4VtkSceneHandler
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Implementation of pure virtual functions...
|
||||
using G4VtkSceneHandler::AddPrimitive;
|
||||
void AddPrimitive(const G4Polyline&) override;
|
||||
void AddPrimitive(const G4Text&) override;
|
||||
void AddPrimitive(const G4Circle&) override;
|
||||
|
||||
@@ -82,6 +82,7 @@ class G4VtkSceneHandler : public G4VSceneHandler
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Required implementation of pure virtual functions...
|
||||
|
||||
using G4VSceneHandler::AddPrimitive;
|
||||
void AddPrimitive(const G4Polyline&) override;
|
||||
void AddPrimitive(const G4Text&) override;
|
||||
void AddPrimitive(const G4Circle&) override;
|
||||
@@ -96,7 +97,10 @@ class G4VtkSceneHandler : public G4VSceneHandler
|
||||
G4VSceneHandler::AddPrimitive(polymarker);
|
||||
}
|
||||
|
||||
using G4VSceneHandler::AddSolid;
|
||||
void AddSolid(const G4Box& box) override;
|
||||
|
||||
using G4VSceneHandler::AddCompound;
|
||||
void AddCompound(const G4Mesh& mesh) override;
|
||||
|
||||
void Modified();
|
||||
|
||||
@@ -26,16 +26,27 @@
|
||||
#ifndef G4VTKUNSTRUCTUREDGRIDPIPELINE_HH
|
||||
#define G4VTKUNSTRUCTUREDGRIDPIPELINE_HH
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "G4VVtkPipeline.hh"
|
||||
#include "G4PseudoScene.hh"
|
||||
|
||||
#include "vtkSmartPointer.h"
|
||||
#include "vtkPoints.h"
|
||||
#include "vtkCharArray.h"
|
||||
#include "vtkDoubleArray.h"
|
||||
#include "vtkUnstructuredGrid.h"
|
||||
#include "vtkStaticCleanUnstructuredGrid.h"
|
||||
#include "vtkLookupTable.h"
|
||||
#include "vtkDiscretizableColorTransferFunction.h"
|
||||
|
||||
class vtkDoubleArray;
|
||||
class vtkClipDataSet;
|
||||
class vtkDataSetMapper;
|
||||
class vtkUnstructuredGridVolumeMapper;
|
||||
class vtkUnstructuredGridVolumeRayCastMapper;
|
||||
class vtkUnstructuredGridVolumeZSweepMapper;
|
||||
class vtkOpenGLProjectedTetrahedraMapper;
|
||||
class vtkActor;
|
||||
|
||||
class G4Mesh;
|
||||
@@ -47,6 +58,11 @@ class G4VtkUnstructuredGridPipeline : public G4VVtkPipeline
|
||||
|
||||
~G4VtkUnstructuredGridPipeline() = default;
|
||||
|
||||
void AddFilter(vtkSmartPointer<vtkUnstructuredGridAlgorithm> f) { filters.push_back(f); }
|
||||
vtkSmartPointer<vtkUnstructuredGridAlgorithm> GetFilter(G4int iFilter) { return filters[iFilter]; }
|
||||
std::size_t GetNumberOfFilters() { return filters.size(); }
|
||||
vtkSmartPointer<vtkUnstructuredGridAlgorithm> GetFinalFilter() { return filters[filters.size() - 1]; }
|
||||
|
||||
void Modified() {};
|
||||
void Clear() {};
|
||||
void Print() {};
|
||||
@@ -62,11 +78,27 @@ class G4VtkUnstructuredGridPipeline : public G4VVtkPipeline
|
||||
PseudoSceneVtkBase(G4PhysicalVolumeModel* pvModel, // input
|
||||
G4int depth,
|
||||
vtkPoints *points,
|
||||
vtkDoubleArray *cellValues,
|
||||
vtkUnstructuredGrid *unstructuredGrid) // input...the following are outputs by reference
|
||||
: fpPVModel(pvModel), fDepth(depth), fpPoints(points),
|
||||
fpGrid(unstructuredGrid), fpCellValues(cellValues)
|
||||
vtkDoubleArray *pointColourValues,
|
||||
vtkDoubleArray *cellColourValues,
|
||||
vtkDoubleArray *pointColourIndices,
|
||||
vtkDoubleArray *cellColourIndices,
|
||||
vtkDiscretizableColorTransferFunction *colourLUT,
|
||||
vtkUnstructuredGrid *unstructuredGrid) // input...the following are outputs by reference
|
||||
: fpPVModel(pvModel), fDepth(depth), fpPoints(points), fpGrid(unstructuredGrid),
|
||||
fpPointColourValues(pointColourValues), fpCellColourValues(cellColourValues),
|
||||
fpPointColourIndices(pointColourIndices), fpCellColourIndices(cellColourIndices),
|
||||
fpColourLUT(colourLUT)
|
||||
{}
|
||||
|
||||
G4int GetNumberOfPoints() {return iPoint;}
|
||||
G4int GetNumberOfCells() {return iCell;}
|
||||
G4int GetNumberOfAddedCells() {return iCellAdd;}
|
||||
void DumpColourMap() {
|
||||
for(auto i : fpColourMap) {
|
||||
G4cout << i.first << " " << i.second << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
using G4PseudoScene::AddSolid; // except for...
|
||||
void AddSolid(const G4VSolid& /*solid*/) override {};
|
||||
@@ -78,17 +110,31 @@ class G4VtkUnstructuredGridPipeline : public G4VVtkPipeline
|
||||
G4int fDepth;
|
||||
vtkSmartPointer<vtkPoints> fpPoints;
|
||||
vtkSmartPointer<vtkUnstructuredGrid> fpGrid;
|
||||
vtkSmartPointer<vtkDoubleArray> fpCellValues;
|
||||
vtkSmartPointer<vtkDoubleArray> fpPointColourValues;
|
||||
vtkSmartPointer<vtkDoubleArray> fpCellColourValues;
|
||||
vtkSmartPointer<vtkDoubleArray> fpPointColourIndices;
|
||||
vtkSmartPointer<vtkDoubleArray> fpCellColourIndices;
|
||||
std::map<std::size_t,double> fpColourMap;
|
||||
vtkSmartPointer<vtkDiscretizableColorTransferFunction> fpColourLUT;
|
||||
std::vector<G4ThreeVector> fpPointVector;
|
||||
std::map<std::size_t, std::size_t> fpPointMap;
|
||||
G4int iPoint = 0;
|
||||
G4int iCell = 0;
|
||||
G4int iCellAdd = 0;
|
||||
};
|
||||
class PseudoSceneForTetCells: public PseudoSceneVtkBase {
|
||||
public:
|
||||
PseudoSceneForTetCells(G4PhysicalVolumeModel* pvModel, // input
|
||||
G4int depth,
|
||||
vtkPoints *points,
|
||||
vtkDoubleArray *cellValues,
|
||||
vtkDoubleArray *pointColourValues,
|
||||
vtkDoubleArray *cellColourValues,
|
||||
vtkDoubleArray *pointColourIndices,
|
||||
vtkDoubleArray *cellColourIndices,
|
||||
vtkDiscretizableColorTransferFunction *colourLUT,
|
||||
vtkUnstructuredGrid *unstructuredGrid) // input...the following are outputs by reference
|
||||
: PseudoSceneVtkBase(pvModel,depth,points,cellValues,unstructuredGrid)
|
||||
: PseudoSceneVtkBase(pvModel,depth,points,pointColourValues,cellColourValues,
|
||||
pointColourIndices, cellColourIndices, colourLUT, unstructuredGrid)
|
||||
{}
|
||||
private:
|
||||
using G4PseudoScene::AddSolid; // except for...
|
||||
@@ -98,11 +144,16 @@ class G4VtkUnstructuredGridPipeline : public G4VVtkPipeline
|
||||
class PseudoSceneForCubicalCells: public PseudoSceneVtkBase {
|
||||
public:
|
||||
PseudoSceneForCubicalCells(G4PhysicalVolumeModel* pvModel, // input
|
||||
G4int depth,
|
||||
vtkPoints *points,
|
||||
vtkDoubleArray *cellValues,
|
||||
vtkUnstructuredGrid *unstructuredGrid) // input...the following are outputs by reference
|
||||
: PseudoSceneVtkBase(pvModel,depth,points,cellValues,unstructuredGrid)
|
||||
G4int depth,
|
||||
vtkPoints *points,
|
||||
vtkDoubleArray *pointColourValues,
|
||||
vtkDoubleArray *cellColourValues,
|
||||
vtkDoubleArray *pointColourIndices,
|
||||
vtkDoubleArray *cellColourIndices,
|
||||
vtkDiscretizableColorTransferFunction *colourLUT,
|
||||
vtkUnstructuredGrid *unstructuredGrid) // input...the following are outputs by reference
|
||||
: PseudoSceneVtkBase(pvModel,depth,points,pointColourValues,cellColourValues,
|
||||
pointColourIndices,cellColourIndices,colourLUT, unstructuredGrid)
|
||||
{}
|
||||
private:
|
||||
using G4PseudoScene::AddSolid; // except for...
|
||||
@@ -112,12 +163,21 @@ class G4VtkUnstructuredGridPipeline : public G4VVtkPipeline
|
||||
|
||||
private:
|
||||
vtkSmartPointer<vtkPoints> points;
|
||||
vtkSmartPointer<vtkDoubleArray> pointValues;
|
||||
vtkSmartPointer<vtkDoubleArray> cellValues;
|
||||
vtkSmartPointer<vtkDoubleArray> pointColourValues;
|
||||
vtkSmartPointer<vtkDoubleArray> cellColourValues;
|
||||
vtkSmartPointer<vtkDoubleArray> pointColourIndices;
|
||||
vtkSmartPointer<vtkDoubleArray> cellColourIndices;
|
||||
vtkSmartPointer<vtkDiscretizableColorTransferFunction> colourLUT;
|
||||
|
||||
vtkSmartPointer<vtkUnstructuredGrid> unstructuredGrid;
|
||||
vtkSmartPointer<vtkStaticCleanUnstructuredGrid> cleanUnstructuredGrid;
|
||||
std::vector<vtkSmartPointer<vtkUnstructuredGridAlgorithm>> filters; // derived types can store filters in this vector
|
||||
vtkSmartPointer<vtkStaticCleanUnstructuredGrid> clean;
|
||||
vtkSmartPointer<vtkClipDataSet> clip;
|
||||
vtkSmartPointer<vtkDataSetMapper> mapper;
|
||||
vtkSmartPointer<vtkUnstructuredGridVolumeRayCastMapper> volumeMapper;
|
||||
vtkSmartPointer<vtkActor> actor;
|
||||
vtkSmartPointer<vtkVolume> volume;
|
||||
};
|
||||
|
||||
|
||||
#endif // G4VTKUNSTRUCTUREDGRIDPIPELINE_HH
|
||||
|
||||
@@ -45,5 +45,9 @@ vtkSmartPointer<vtkMatrix4x4> G4Transform3DToVtkMatrix4x4(const G4Transform3D& g
|
||||
vtkSmartPointer<vtkPlane> G4Plane3DToVtkPlane(const G4Plane3D& g4plane);
|
||||
G4Plane3D VtkPlaneToG4Plane3D(vtkPlane* vtkPlane);
|
||||
void MaxBounds(G4double* maxBound, G4double* boundToCheck);
|
||||
std::size_t MakeHash(const G4ThreeVector &v);
|
||||
std::size_t MakeHash(const G4Colour &c);
|
||||
|
||||
|
||||
|
||||
#endif // G4VTKUTILITY_HH
|
||||
|
||||
@@ -82,18 +82,18 @@ class vtkGeant4Callback : public vtkCommand
|
||||
auto cp = cam->GetPosition();
|
||||
auto fp = cam->GetFocalPoint();
|
||||
auto ud = cam->GetViewUp();
|
||||
auto ps = cam->GetParallelScale();
|
||||
auto cd = std::sqrt(std::pow(cp[0] - fp[0], 2) + std::pow(cp[1] - fp[1], 2)
|
||||
+ std::pow(cp[2] - fp[2], 2));
|
||||
|
||||
fVP->SetCurrentTargetPoint(G4Point3D(fp[0], fp[1], fp[2]));
|
||||
fVP->SetViewpointDirection(
|
||||
(G4Point3D(cp[0], cp[1], cp[2]) - G4Point3D(fp[0], fp[1], fp[2])).unit());
|
||||
fVP->SetViewpointDirection((G4Point3D(cp[0], cp[1], cp[2]) - G4Point3D(fp[0], fp[1], fp[2])).unit());
|
||||
fVP->SetUpVector(G4Vector3D(ud[0], ud[1], ud[2]));
|
||||
|
||||
if (cam->GetParallelProjection() != 0) {
|
||||
fVP->SetZoomFactor(parallelScale / cam->GetParallelScale());
|
||||
fVP->SetZoomFactor(parallelScale / ps);
|
||||
}
|
||||
else {
|
||||
auto cd = std::sqrt(std::pow(cp[0] - fp[0], 2) + std::pow(cp[1] - cp[1], 2)
|
||||
+ std::pow(cp[2] - cp[2], 2));
|
||||
fVP->SetZoomFactor(cameraDistance / cd);
|
||||
}
|
||||
}
|
||||
@@ -127,8 +127,12 @@ class vtkInfoCallback : public vtkCommand
|
||||
double* foc = cam->GetFocalPoint();
|
||||
double viewAngle = cam->GetViewAngle();
|
||||
double distance = cam->GetDistance();
|
||||
double near;
|
||||
double far;
|
||||
cam->GetClippingRange(near,far);
|
||||
double parallelScale = cam->GetParallelScale();
|
||||
|
||||
|
||||
if (pos == nullptr) return;
|
||||
|
||||
// Get current time
|
||||
@@ -145,10 +149,11 @@ class vtkInfoCallback : public vtkCommand
|
||||
"camera focal point : %.1f %.1f %.1f \n"
|
||||
"view angle : %.1f\n"
|
||||
"distance : %.1f\n"
|
||||
"clip near/far : %.1f %.1f\n"
|
||||
"parallel scale : %.1f\n"
|
||||
"number actors : %i\n"
|
||||
"fps : %.1f",
|
||||
pos[0], pos[1], pos[2], foc[0], foc[1], foc[2], viewAngle, distance, parallelScale,
|
||||
pos[0], pos[1], pos[2], foc[0], foc[1], foc[2], viewAngle, distance, near, far, parallelScale,
|
||||
nActors, fps);
|
||||
if (this->TextActor != nullptr) {
|
||||
this->TextActor->SetInput(this->TextBuff);
|
||||
@@ -219,6 +224,7 @@ class G4VtkViewer : public G4VViewer
|
||||
void ExportVRMLScene(G4String);
|
||||
void ExportVTPScene(G4String);
|
||||
void ExportGLTFScene(G4String);
|
||||
void ExportJSONRenderWindowScene(G4String);
|
||||
void ExportVTPCutter(G4String fileName);
|
||||
void ExportFormatStore(G4String fileName, G4String store);
|
||||
|
||||
@@ -251,9 +257,15 @@ class G4VtkViewer : public G4VViewer
|
||||
const G4double imageBottomLeft[2], const G4double worldBottomLeft[2],
|
||||
const G4double imageTopRight[2], const G4double worldTopRight[2],
|
||||
const G4double rot[3], const G4double trans[3]);
|
||||
void Add3DOverlay(const G4String& fileName, const G4double colour[3], const G4double alpha,
|
||||
const G4double scale[3], const G4double rotation[3],
|
||||
const G4double translation[3]);
|
||||
void AddGeometryOverlay(const G4String& fileName, const G4double colour[3], const G4double alpha,
|
||||
const G4String& representation,
|
||||
const G4double scale[3], const G4double rotation[3],
|
||||
const G4double translation[3]);
|
||||
|
||||
void Render() {_renderWindow->Render();}
|
||||
void StartInteractor() {
|
||||
G4cout << "StartInteractor" << G4endl;
|
||||
_renderWindow->GetInteractor()->Start();}
|
||||
|
||||
void Print();
|
||||
|
||||
@@ -275,6 +287,9 @@ class G4VtkViewer : public G4VViewer
|
||||
|
||||
protected:
|
||||
G4bool firstSetView = true;
|
||||
G4bool firstFinishView = true;
|
||||
G4double cameraDistance;
|
||||
|
||||
vtkNew<vtkImplicitPlaneRepresentation> cutterPlaneRepresentation;
|
||||
vtkNew<vtkImplicitPlaneWidget2> cutterPlaneWidget;
|
||||
|
||||
@@ -282,6 +297,11 @@ class G4VtkViewer : public G4VViewer
|
||||
vtkNew<vtkImplicitPlaneWidget2> clipperPlaneWidget;
|
||||
|
||||
vtkNew<vtkCameraOrientationWidget> camOrientWidget;
|
||||
|
||||
bool bCutter = false;
|
||||
bool bClipper = false;
|
||||
bool bHud = false;
|
||||
bool bOrientation = false;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -74,6 +74,7 @@ class G4VtkVisContext
|
||||
green(vc2.green),
|
||||
blue(vc2.blue),
|
||||
alpha(vc2.alpha),
|
||||
fSize(vc2.fSize),
|
||||
fDrawingStyle(vc2.fDrawingStyle)
|
||||
{}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user