Import Geant4 11.4.0.beta source tree
This commit is contained in:
@@ -6,6 +6,66 @@ It must **not** be used as a substitute for writing good git commit messages!
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
## 2025-06-17 Guy Barrand (vis_toolssg-V11-03-07)
|
||||
- G4ToolsSGViewer.hh: in mouse_move(), use the event.shift_modifier() method, introduced
|
||||
in g4tools-V11-03-03, to pass in pan mode.
|
||||
Suppress then the no more needed fKeyPressed, fKeyShift fields and the related logic.
|
||||
|
||||
## 2025-06-02 Guy Barrand (vis_toolssg-V11-03-06)
|
||||
- G4ToolsSGViewer.hh: have the GetWindowSize, GetRenderAreaSize methods to retrieve the actual sizes of the "seen/visibl window" and
|
||||
of the "render area" size. These may return different sizes, for example with Qt/OpenGL on Mac and Windows.
|
||||
- G4ToolsSGViewer::SetView: use the new GetWindowSize, GetRenderAreaSize methods to set the "marker scale" on G4ToolsSGSceneHandler.
|
||||
- G4ToolsSGSceneHandler.hh, .cc: handle the fMarkerScale field. Used in AddPrimitive(G4Text).
|
||||
- G4ToolsSGQtGLESViewer.hh, G4ToolsSGQtZBViewer.hh, G4ToolsSGOffscreenViewer.hh: supress the SetView method no more needed
|
||||
because of the upper "marker scale" modifications in G4ToolsSGViewer.hh.
|
||||
|
||||
## 2025-05-29 John Allison (vis_toolssg-V11-03-05)
|
||||
- Allow accumulation of transients (trajectories) during multithreading.
|
||||
- G4ToolsSGViewer.hh:
|
||||
- Remove SwitchToVisSubThread and SwitchToMasterThread.
|
||||
- No action needed on thread switching.
|
||||
- G4ToolsSGSceneHandler.cc:
|
||||
- G4ToolsSGSceneHandler::GetOrCreateNode():
|
||||
- Remove restriction on multithreading:
|
||||
- Remove if (!G4Threading::IsMasterThread()) return nullptr;
|
||||
- Trajectories are stored in the database during the run, and displayed at end
|
||||
of run. Try "/run/beamOn 1000" (exampleB1).
|
||||
- All events are displayed at end of run.
|
||||
- Of course, change of style, time evolution, view cloning, etc., only
|
||||
operates on kept events, as before.
|
||||
|
||||
## 2025-05-25 John Allison (vis_toolssg-V11-03-04)
|
||||
- G4ToolsSGSceneHandler.cc:
|
||||
- Respect line width in vis attributes and view parameters.
|
||||
|
||||
## 2025-03-21 Ben Morgan (vis_toolssg-V11-03-03)
|
||||
- Modernize g4tools macro-based loops with range-based for.
|
||||
- Update raw for loops with range-for where possible.
|
||||
|
||||
## 2025-03-06 John Allison (vis_toolssg-V11-03-02)
|
||||
- G4ToolsSGViewer.hh:
|
||||
- Implement CompareForTransientsRedraw().
|
||||
- Take advantage of ProcessTransients(), which reconstructs that part of
|
||||
the graphical database for transient objects, e.g., trajectories,
|
||||
without reconstructing the "permanent" (run-duration) objects, e.g.,
|
||||
the detector. In other words, something short of a complete "kernel
|
||||
visit". For example, if the time window changes.
|
||||
- Maximises the efficiency of the recently implemented "generic" time
|
||||
windowing.
|
||||
|
||||
## 2025-02-13 John Allison (vis_toolssg-V11-03-01)
|
||||
- G4ToolsSGViewer.hh: CompareForKernelVisit:
|
||||
- Cause kernel visit if viewer start/end time changes.
|
||||
- This is to take advantage of the new generic time window - modeling-V11-03-04.
|
||||
|
||||
## 2025-01-06 John Allison (vis_toolssg-V11-03-00)
|
||||
- Co-works: visman-V11-03-00, interfaces-V11-03-00, modeling-V11-03-00,
|
||||
opengl-V11-03-00, visQt3D-V11-03-00, openinventor-V11-03-00,
|
||||
greps-V11-03-00.
|
||||
- Re-instate the transparency slider (see lengthy explanation in management/History).
|
||||
- G4Qt3DViewer:
|
||||
- Initiate kernel visit if TransparencyByDepth or its options change.
|
||||
|
||||
## 2024-06-21 Ben Morgan (vis_toolssg-V1-02-02)
|
||||
- Use runtime checks for MT mode.
|
||||
|
||||
|
||||
@@ -75,11 +75,6 @@ public:
|
||||
fSGViewer->set_do_transparency(true);
|
||||
fSGViewer->set_top_to_bottom(false); //if using tools::fpng, tools::toojpeg.
|
||||
}
|
||||
virtual void SetView() {
|
||||
//::printf("debug : G4ToolsSGOffscreenViewer::SetView\n");
|
||||
fVP.SetGlobalMarkerScale(1); //WARNING: for __APPLE__, the G4ToolsSGQtViewer set it to 2.
|
||||
parent::SetView();
|
||||
}
|
||||
|
||||
virtual void DrawView() {
|
||||
if (!fNeedKernelVisit) KernelVisitDecision();
|
||||
|
||||
@@ -106,27 +106,6 @@ public:
|
||||
fSGViewer->enable_keyboard_focus();
|
||||
}
|
||||
|
||||
virtual void SetView() {
|
||||
#ifdef __APPLE__
|
||||
if(fSGQWidget && fSGViewer) {
|
||||
if( (2*fSGQWidget->width() == int(fSGViewer->width())) &&
|
||||
(2*fSGQWidget->height() == int(fSGViewer->height())) ){
|
||||
// With Qt/Cocoa, the received size in
|
||||
// tools::sg::glarea::resizeGL is twice the QWidget::[width(),height()]!
|
||||
// In general it does not pose problem, except when rendering 2D texts.
|
||||
// In order to have similar sizes than other platforms, we have to double
|
||||
// their pixel heights.
|
||||
fVP.SetGlobalMarkerScale(2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
parent::SetView();
|
||||
}
|
||||
|
||||
virtual void UpdateGUISceneTree() {
|
||||
if (fUIQt) fUIQt->UpdateSceneTree(fSceneTree);
|
||||
}
|
||||
|
||||
protected:
|
||||
G4UIQt* fUIQt = nullptr;
|
||||
QWidget* fSGQWidget;
|
||||
|
||||
@@ -105,27 +105,6 @@ public:
|
||||
fSGViewer->enable_keyboard_focus();
|
||||
}
|
||||
|
||||
virtual void SetView() {
|
||||
#ifdef __APPLE__
|
||||
if(fSGQWidget && fSGViewer) {
|
||||
if( (2*fSGQWidget->width() == int(fSGViewer->width())) &&
|
||||
(2*fSGQWidget->height() == int(fSGViewer->height())) ){
|
||||
// With Qt/Cocoa, the received size in
|
||||
// tools::sg::glarea::resizeGL is twice the QWidget::[width(),height()]!
|
||||
// In general it does not pose problem, except when rendering 2D texts.
|
||||
// In order to have similar sizes than other platforms, we have to double
|
||||
// their pixel heights.
|
||||
fVP.SetGlobalMarkerScale(2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
parent::SetView();
|
||||
}
|
||||
|
||||
virtual void UpdateGUISceneTree() {
|
||||
if (fUIQt) fUIQt->UpdateSceneTree(fSceneTree);
|
||||
}
|
||||
|
||||
protected:
|
||||
G4UIQt* fUIQt = nullptr;
|
||||
QWidget* fSGQWidget;
|
||||
|
||||
@@ -68,6 +68,8 @@ public:
|
||||
|
||||
void TouchPlotters(tools::sg::node&);
|
||||
|
||||
void SetMarkerScale(double);
|
||||
|
||||
protected:
|
||||
G4ToolsSGSceneHandler(const G4ToolsSGSceneHandler&);
|
||||
G4ToolsSGSceneHandler& operator=(const G4ToolsSGSceneHandler&){return *this;}
|
||||
@@ -90,7 +92,8 @@ protected:
|
||||
std::vector<G4ToolsSGNode*> fpPhysicalVolumeObjects; // Multiple worlds
|
||||
|
||||
tools::sg::base_freetype* fFreetypeNode;
|
||||
|
||||
double fMarkerScale;
|
||||
|
||||
using Region_h1 = std::pair<unsigned int,int>;
|
||||
using Region_h2 = std::pair<unsigned int,int>;
|
||||
std::vector<Region_h1> fRegionH1s;
|
||||
|
||||
@@ -54,11 +54,8 @@ class G4ToolsSGViewer : public G4VViewer, tools::sg::device_interactor {
|
||||
typedef G4VViewer parent;
|
||||
typedef tools::sg::device_interactor parent_interactor;
|
||||
public: //tools::sg::device_interactor interface.
|
||||
virtual void key_press(const tools::sg::key_down_event& a_event) {
|
||||
fKeyPressed = true;
|
||||
fKeyShift = a_event.key() == tools::sg::key_shift()?true:false;
|
||||
}
|
||||
virtual void key_release(const tools::sg::key_up_event&) {fKeyPressed = false;}
|
||||
virtual void key_press(const tools::sg::key_down_event&) {}
|
||||
virtual void key_release(const tools::sg::key_up_event&) {}
|
||||
virtual void mouse_press(const tools::sg::mouse_down_event& a_event) {
|
||||
fMousePressed = true;
|
||||
fMousePressedX = a_event.x();
|
||||
@@ -75,8 +72,7 @@ public: //tools::sg::device_interactor interface.
|
||||
|
||||
if (fMousePressed) {
|
||||
|
||||
if (fKeyPressed && fKeyShift) { // Translation (pan)
|
||||
|
||||
if (a_event.shift_modifier()) { // Translation (pan)
|
||||
const G4double sceneRadius = fSGSceneHandler.GetScene()->GetExtent().GetExtentRadius();
|
||||
const G4double scale = 300; // Roughly pixels per window, empirically chosen
|
||||
const G4double dxScene = dx*sceneRadius/scale;
|
||||
@@ -124,8 +120,6 @@ public:
|
||||
,fSGSession(a_session)
|
||||
,fSGSceneHandler(a_scene_handler)
|
||||
,fSGViewer(nullptr)
|
||||
,fKeyPressed(false)
|
||||
,fKeyShift(false)
|
||||
,fMousePressed(false)
|
||||
,fMousePressedX(0)
|
||||
,fMousePressedY(0)
|
||||
@@ -148,8 +142,6 @@ protected:
|
||||
,fSGSession(a_from.fSGSession)
|
||||
,fSGSceneHandler(a_from.fSGSceneHandler)
|
||||
,fSGViewer(nullptr)
|
||||
,fKeyPressed(false)
|
||||
,fKeyShift(false)
|
||||
,fMousePressed(false)
|
||||
,fMousePressedX(0)
|
||||
,fMousePressedY(0)
|
||||
@@ -214,6 +206,22 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
{// With Qt/Cocoa/OpenGL, Qt/Windows/OpenGL, the received size in
|
||||
// tools::sg::glarea::resizeGL is the QWidget::[width(),height()] multiplied by the "devicePixelRatio"
|
||||
// (with a value of 2 seen on a MacBookPro and 1.5 seen on a Windows laptop).
|
||||
// In general it does not pose problem, except when rendering 2D texts.
|
||||
// In order to have similar sizes than other drivers, we adapt their scale accordingly.
|
||||
unsigned int ww,wh;
|
||||
if(GetWindowSize(ww,wh)) {
|
||||
unsigned int raw,rah;
|
||||
if(GetRenderAreaSize(raw,rah)) {
|
||||
if(ww!=0) {
|
||||
double width_ratio = double(raw)/double(ww);
|
||||
fSGSceneHandler.SetMarkerScale(width_ratio);
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////
|
||||
@@ -274,15 +282,23 @@ public:
|
||||
virtual void ClearView() {}
|
||||
|
||||
virtual void DrawView() {
|
||||
|
||||
if (!fNeedKernelVisit) KernelVisitDecision();
|
||||
G4bool kernelVisitWasNeeded = fNeedKernelVisit; // Keep (ProcessView resets).
|
||||
fLastVP = fVP;
|
||||
ProcessView(); // Clears store and processes scene only if necessary.
|
||||
|
||||
if (kernelVisitWasNeeded) {
|
||||
// We might need to do something if the kernel was visited.
|
||||
} else {
|
||||
} else { // Or even if it was not!
|
||||
if (!fTransientsNeedRedrawing) CompareForTransientsRedraw(fLastVP);
|
||||
if (fTransientsNeedRedrawing) {
|
||||
ProcessTransients();
|
||||
}
|
||||
}
|
||||
|
||||
FinishView (); // Flush streams and/or swap buffers.
|
||||
|
||||
fLastVP = fVP;
|
||||
}
|
||||
|
||||
virtual void ShowView() {FinishView();}
|
||||
@@ -296,31 +312,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void SwitchToVisSubThread() {}
|
||||
|
||||
virtual void SwitchToMasterThread() {
|
||||
if (G4Threading::IsMultithreadedApplication()) {
|
||||
// I have not figured out how to draw during a run.
|
||||
//
|
||||
// Setting fNeedKernelVisit=true causes scene deletion and a complete rebuild,
|
||||
// including trajectories, hits, etc. from kept events.
|
||||
//
|
||||
// Clearly this is a limitation because even if you run 1000 events you only
|
||||
// get those kept (default 100), and even worse, if end-if-event-action is
|
||||
// "refresh", you only get one event (the last I think).
|
||||
//
|
||||
// Also, strictly, there is no need to rebuid run-duration models (detector),
|
||||
// but a complete rebuild is the easiest way (already imeplemented).
|
||||
//
|
||||
// Only do this if there are end-of-event models (e.g., trajectories) that
|
||||
// may require it.
|
||||
if (fSceneHandler.GetScene() && fSceneHandler.GetScene()->GetEndOfEventModelList().size()) {
|
||||
fNeedKernelVisit = true;
|
||||
DrawView(); // Draw trajectories, etc., from kept events
|
||||
}
|
||||
}
|
||||
public:
|
||||
G4bool GetWindowSize(unsigned int& a_w,unsigned int& a_h) {
|
||||
if(!fSGViewer) {a_w = 0;a_h = 0;return false;}
|
||||
return fSGViewer->window_size(a_w,a_h);
|
||||
}
|
||||
G4bool GetRenderAreaSize(unsigned int& a_w,unsigned int& a_h) {
|
||||
if(!fSGViewer) {a_w = 0;a_h = 0;return false;}
|
||||
fSGViewer->render_area_size(a_w,a_h);
|
||||
return true;
|
||||
}
|
||||
|
||||
//SG_VIEWER* sg_viewer() {return fSGViewer;}
|
||||
protected:
|
||||
void KernelVisitDecision () {
|
||||
@@ -359,16 +360,14 @@ protected:
|
||||
fVP.GetDefaultTextVisAttributes()->GetColour()) ||
|
||||
(vp.GetBackgroundColour ()!= fVP.GetBackgroundColour ())||
|
||||
(vp.IsPicking () != fVP.IsPicking ()) ||
|
||||
// Scaling for Open Inventor is done by the scene handler so it
|
||||
// Scaling for ToolsSG is done by the scene handler so it
|
||||
// needs a kernel visit. (In this respect, it differs from the
|
||||
// OpenGL drivers, where it's done in SetView.)
|
||||
(vp.GetScaleFactor () != fVP.GetScaleFactor ()) ||
|
||||
(vp.GetVisAttributesModifiers() !=
|
||||
fVP.GetVisAttributesModifiers()) ||
|
||||
(vp.IsSpecialMeshRendering() !=
|
||||
fVP.IsSpecialMeshRendering()) ||
|
||||
(vp.GetSpecialMeshRenderingOption() !=
|
||||
fVP.GetSpecialMeshRenderingOption())
|
||||
(vp.GetVisAttributesModifiers() != fVP.GetVisAttributesModifiers()) ||
|
||||
(vp.IsSpecialMeshRendering() != fVP.IsSpecialMeshRendering()) ||
|
||||
(vp.GetSpecialMeshRenderingOption()!= fVP.GetSpecialMeshRenderingOption())||
|
||||
(vp.GetTransparencyByDepth() != fVP.GetTransparencyByDepth())
|
||||
)
|
||||
return true;
|
||||
|
||||
@@ -402,15 +401,19 @@ protected:
|
||||
(vp.GetSpecialMeshVolumes() != fVP.GetSpecialMeshVolumes()))
|
||||
return true;
|
||||
|
||||
if (vp.GetTransparencyByDepth() > 0. &&
|
||||
vp.GetTransparencyByDepthOption() != fVP.GetTransparencyByDepthOption())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
G4bool CompareForTransientsRedraw(G4ViewParameters& vp) {
|
||||
if (vp.GetTimeParameters() != fVP.GetTimeParameters()) {
|
||||
return fTransientsNeedRedrawing = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// void keyPressEvent (KeyEvent*);
|
||||
// void keyReleaseEvent (KeyEvent*);
|
||||
// void mouseDoubleClickEvent(MouseEvent*);
|
||||
// void mouseMoveEvent (MouseEvent*);
|
||||
// void mousePressEvent (MouseEvent*);
|
||||
// void mouseReleaseEvent (MouseEvent*);
|
||||
// void wheelEvent (WheelEvent*);
|
||||
|
||||
protected:
|
||||
void CreateSG(tools::sg::base_camera* a_camera,const G4Vector3D& a_light_dir) {
|
||||
@@ -533,8 +536,6 @@ protected:
|
||||
SG_VIEWER* fSGViewer;
|
||||
G4ViewParameters fLastVP; // Memory for making kernel visit decisions.
|
||||
|
||||
G4bool fKeyPressed;
|
||||
G4bool fKeyShift;
|
||||
G4bool fMousePressed;
|
||||
G4double fMousePressedX, fMousePressedY;
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ G4ToolsSGSceneHandler::G4ToolsSGSceneHandler
|
||||
(G4VGraphicsSystem& system, const G4String& name)
|
||||
:parent(system, fSceneIdCount++, name)
|
||||
,fFreetypeNode(0)
|
||||
,fMarkerScale(1)
|
||||
{
|
||||
//::printf("debug : G4ToolsSGSceneHandler : %lu, %s\n",this,name.c_str());
|
||||
EstablishBaseNodes();
|
||||
@@ -122,9 +123,6 @@ void G4ToolsSGSceneHandler::EstablishBaseNodes()
|
||||
tools::sg::separator* G4ToolsSGSceneHandler::GetOrCreateNode()
|
||||
{ // Retrieve or create a G4ToolsSGNode node suitable for next solid or primitive
|
||||
|
||||
// For time being, avoid errors in MT mode - see G4ToolsSGViewer::SwitchToMasterThread
|
||||
if (!G4Threading::IsMasterThread()) return nullptr;
|
||||
|
||||
if (fReadyForTransients) { // All transients hang from this node
|
||||
tools::sg::separator* sep = new tools::sg::separator;
|
||||
fpTransient3DObjects.add(sep);
|
||||
@@ -246,15 +244,16 @@ void G4ToolsSGSceneHandler::AddPrimitive(const G4Polyline& a_polyline)
|
||||
|
||||
{tools::sg::draw_style* ds = new tools::sg::draw_style;
|
||||
ds->style = tools::sg::draw_lines;
|
||||
ds->line_width = 1;
|
||||
auto visAtts = GetCurrentViewer()->GetApplicableVisAttributes(a_polyline.GetVisAttributes());
|
||||
ds->line_width = GetLineWidth(visAtts); // Multiplies by GetGlobalLineWidthScale
|
||||
parentNode->add(ds);}
|
||||
|
||||
tools::sg::vertices* vtxs = new tools::sg::vertices;
|
||||
vtxs->mode = tools::gl::line_strip(); //polyline
|
||||
parentNode->add(vtxs);
|
||||
|
||||
{for (size_t i = 0; i < a_polyline.size(); ++i) {
|
||||
vtxs->add(float(a_polyline[i].x()),float(a_polyline[i].y()),float(a_polyline[i].z()));
|
||||
{for (const auto& i : a_polyline) {
|
||||
vtxs->add(float(i.x()),float(i.y()),float(i.z()));
|
||||
}}
|
||||
|
||||
}
|
||||
@@ -298,8 +297,8 @@ void G4ToolsSGSceneHandler::AddPrimitive (const G4Polymarker& a_polymarker)
|
||||
currentNode->add(ds);
|
||||
tools::sg::vertices* vtxs = new tools::sg::vertices;
|
||||
vtxs->mode = tools::gl::points();
|
||||
{for (size_t i = 0; i < a_polymarker.size(); ++i) {
|
||||
vtxs->add(float(a_polymarker[i].x()),float(a_polymarker[i].y()),float(a_polymarker[i].z()));
|
||||
{for (const auto& i : a_polymarker) {
|
||||
vtxs->add(float(i.x()),float(i.y()),float(i.z()));
|
||||
}}
|
||||
currentNode->add(vtxs);
|
||||
}break;
|
||||
@@ -313,8 +312,8 @@ void G4ToolsSGSceneHandler::AddPrimitive (const G4Polymarker& a_polymarker)
|
||||
}
|
||||
markers->size = diameter;
|
||||
markers->style = tools::sg::marker_circle_line;
|
||||
for (size_t i = 0; i < a_polymarker.size(); ++i) {
|
||||
markers->add(float(a_polymarker[i].x()),float(a_polymarker[i].y()),float(a_polymarker[i].z()));
|
||||
for (const auto& i : a_polymarker) {
|
||||
markers->add(float(i.x()),float(i.y()),float(i.z()));
|
||||
}
|
||||
currentNode->add(markers);}
|
||||
}break;
|
||||
@@ -328,14 +327,17 @@ void G4ToolsSGSceneHandler::AddPrimitive (const G4Polymarker& a_polymarker)
|
||||
}
|
||||
markers->size = side;
|
||||
markers->style = tools::sg::marker_square_line;
|
||||
for (size_t i = 0; i < a_polymarker.size(); ++i) {
|
||||
markers->add(float(a_polymarker[i].x()),float(a_polymarker[i].y()),float(a_polymarker[i].z()));
|
||||
for (const auto& i : a_polymarker) {
|
||||
markers->add(float(i.x()),float(i.y()),float(i.z()));
|
||||
}
|
||||
currentNode->add(markers);}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void G4ToolsSGSceneHandler::SetMarkerScale(double a_scale) {fMarkerScale = a_scale;}
|
||||
|
||||
void G4ToolsSGSceneHandler::AddPrimitive(const G4Text& a_text)
|
||||
{
|
||||
//::printf("debug : G4ToolsSGSceneHandler::AddPrimitive(const G4Text&) : 000 : \"%s\"\n",a_text.GetText().c_str());
|
||||
@@ -371,6 +373,7 @@ void G4ToolsSGSceneHandler::AddPrimitive(const G4Text& a_text)
|
||||
|
||||
MarkerSizeType sizeType;
|
||||
G4double size = GetMarkerSize(a_text, sizeType);
|
||||
size *= fMarkerScale;
|
||||
|
||||
{const auto& colour = GetTextColour(a_text);
|
||||
tools::sg::rgba* mat = new tools::sg::rgba();
|
||||
@@ -566,7 +569,8 @@ void G4ToolsSGSceneHandler::AddPrimitive(const G4Polyhedron& a_polyhedron)
|
||||
|
||||
{tools::sg::draw_style* ds = new tools::sg::draw_style;
|
||||
ds->style = tools::sg::draw_lines;
|
||||
ds->line_width = 1;
|
||||
auto visAtts = GetCurrentViewer()->GetApplicableVisAttributes(a_polyhedron.GetVisAttributes());
|
||||
ds->line_width = GetLineWidth(visAtts); // Multiplies by GetGlobalLineWidthScale
|
||||
sep->add(ds);}
|
||||
|
||||
tools::sg::vertices* vtxs = new tools::sg::vertices;
|
||||
@@ -606,10 +610,10 @@ inline void SetRegionStyles(tools::xml::styles& a_styles,
|
||||
}
|
||||
|
||||
inline tools::xml::styles::style_t* find_style(tools::xml::styles& a_styles,const std::string& a_name) {
|
||||
tools_vforit(tools::xml::styles::named_style_t,a_styles.named_styles(),it){
|
||||
if((*it).first==a_name) return &((*it).second);
|
||||
for(auto& style : a_styles.named_styles()) {
|
||||
if(style.first==a_name) return &(style.second);
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline void SetPlotterStyles(tools::sg::plots& a_plots,
|
||||
@@ -622,54 +626,51 @@ inline void SetPlotterStyles(tools::sg::plots& a_plots,
|
||||
_tools_styles.add_colormap("default",tools::sg::style_default_colormap());
|
||||
_tools_styles.add_colormap("ROOT",tools::sg::style_ROOT_colormap());
|
||||
|
||||
{tools_vforcit(G4PlotterManager::NamedStyle,_styles,it) {
|
||||
for(const auto& [name, style_items] : _styles) {
|
||||
tools::xml::styles::style_t _tools_style;
|
||||
tools_vforcit(G4PlotterManager::StyleItem,(*it).second,its) {
|
||||
const G4String& param = (*its).first;
|
||||
for(const auto& [param, value] : style_items) {
|
||||
if(param.find('.')==std::string::npos) {
|
||||
const G4String& value = (*its).second;
|
||||
_tools_style.push_back(tools::xml::styles::style_item_t(param,value));
|
||||
_tools_style.push_back(tools::xml::styles::style_item_t(param,value));
|
||||
}
|
||||
}
|
||||
_tools_styles.add_style((*it).first,_tools_style);
|
||||
}}
|
||||
_tools_styles.add_style(name, _tools_style);
|
||||
}
|
||||
|
||||
// sub styles:
|
||||
{tools_vforcit(G4PlotterManager::NamedStyle,_styles,it) {
|
||||
tools_vforcit(G4PlotterManager::StyleItem,(*it).second,its) {
|
||||
const G4String& param = (*its).first;
|
||||
for(const auto& [name, style_items] : _styles) {
|
||||
for(const auto& [param, value] : style_items) {
|
||||
std::string::size_type pos = param.rfind('.');
|
||||
if(pos!=std::string::npos) {
|
||||
std::string sub_style = (*it).first+"."+param.substr(0,pos);
|
||||
std::string sub_style = name + "." + param.substr(0,pos);
|
||||
G4String parameter = param.substr(pos+1,param.size()-pos);
|
||||
const G4String& value = (*its).second;
|
||||
tools::xml::styles::style_t* _tools_style = find_style(_tools_styles,sub_style);
|
||||
if(_tools_style) {
|
||||
if(_tools_style) {
|
||||
_tools_style->push_back(tools::xml::styles::style_item_t(parameter,value));
|
||||
} else {
|
||||
} else {
|
||||
tools::xml::styles::style_t _tools_style_2;
|
||||
_tools_style_2.push_back(tools::xml::styles::style_item_t(parameter,value));
|
||||
_tools_style_2.push_back(tools::xml::styles::style_item_t(parameter,value));
|
||||
_tools_styles.add_style(sub_style,_tools_style_2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
{unsigned int number = a_plots.number();
|
||||
unsigned int number = a_plots.number();
|
||||
for(unsigned int index=0;index<number;index++) {
|
||||
tools::sg::plotter* _plotter = a_plots.find_plotter(index);
|
||||
if(_plotter) {
|
||||
tools_vforcit(G4String,a_plotter_styles,it) {
|
||||
SetRegionStyles(_tools_styles,a_plots,*_plotter,*it);
|
||||
for(const auto& style : a_plotter_styles) {
|
||||
SetRegionStyles(_tools_styles,a_plots,*_plotter,style);
|
||||
}
|
||||
}
|
||||
}}
|
||||
{tools_vforcit(G4Plotter::RegionStyle,a_region_styles,it) {
|
||||
tools::sg::plotter* _plotter = a_plots.find_plotter((*it).first);
|
||||
}
|
||||
|
||||
for(const auto& [region, style] : a_region_styles) {
|
||||
tools::sg::plotter* _plotter = a_plots.find_plotter(region);
|
||||
if(_plotter) {
|
||||
SetRegionStyles(_tools_styles,a_plots,*_plotter,(*it).second);
|
||||
SetRegionStyles(_tools_styles, a_plots, *_plotter, style);
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
inline void SetPlotterParameters(tools::sg::cmaps_t& a_cmaps,tools::sg::plots& a_plots,
|
||||
@@ -681,11 +682,11 @@ inline void SetPlotterParameters(tools::sg::cmaps_t& a_cmaps,tools::sg::plots& a
|
||||
// x_axis.divisions
|
||||
// x_axis.line_style.color
|
||||
// background_style.back_color
|
||||
tools_vforcit(G4Plotter::RegionParameter,a_region_parameters,it) {
|
||||
tools::sg::plotter* _plotter = a_plots.find_plotter((*it).first);
|
||||
for(const auto& [region,param] : a_region_parameters) {
|
||||
tools::sg::plotter* _plotter = a_plots.find_plotter(region);
|
||||
if(_plotter) {
|
||||
const G4String& parameter = (*it).second.first;
|
||||
const G4String& value = (*it).second.second;
|
||||
const G4String& parameter = param.first;
|
||||
const G4String& value = param.second;
|
||||
tools::sg::field* fd = _plotter->find_field_by_name(parameter);
|
||||
if(!fd) fd = _plotter->find_field_by_name(_plotter->s_cls()+"."+parameter);
|
||||
if(fd) {if(fd->s2value(value)) continue;}
|
||||
@@ -707,15 +708,15 @@ void G4ToolsSGSceneHandler::SetPlotterHistograms(tools::sg::plots& a_plots) {
|
||||
a_plots.clear();
|
||||
G4UImanager* UI = G4UImanager::GetUIpointer();
|
||||
if(UI==NULL) return;
|
||||
{tools_vforcit(Region_h1,fRegionH1s,it) {
|
||||
tools::sg::plotter* _plotter = a_plots.find_plotter((*it).first);
|
||||
|
||||
for(const auto& [region, hid] : fRegionH1s) {
|
||||
tools::sg::plotter* _plotter = a_plots.find_plotter(region);
|
||||
if(_plotter) {
|
||||
int hid = (*it).second;
|
||||
std::ostringstream os;
|
||||
os << hid;
|
||||
std::string cmd("/analysis/h1/get ");
|
||||
cmd += std::string(os.str());
|
||||
auto keepControlVerbose = UI->GetVerboseLevel();
|
||||
auto keepControlVerbose = UI->GetVerboseLevel();
|
||||
UI->SetVerboseLevel(0);
|
||||
G4int status = UI->ApplyCommand(cmd.c_str());
|
||||
UI->SetVerboseLevel(keepControlVerbose);
|
||||
@@ -736,11 +737,11 @@ void G4ToolsSGSceneHandler::SetPlotterHistograms(tools::sg::plots& a_plots) {
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
}}
|
||||
{tools_vforcit(Region_h2,fRegionH2s,it) {
|
||||
tools::sg::plotter* _plotter = a_plots.find_plotter((*it).first);
|
||||
}
|
||||
|
||||
for(const auto& [region, hid] : fRegionH2s) {
|
||||
tools::sg::plotter* _plotter = a_plots.find_plotter(region);
|
||||
if(_plotter) {
|
||||
int hid = (*it).second;
|
||||
std::ostringstream os;
|
||||
os << hid;
|
||||
std::string cmd("/analysis/h2/get ");
|
||||
@@ -766,7 +767,7 @@ void G4ToolsSGSceneHandler::SetPlotterHistograms(tools::sg::plots& a_plots) {
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
class plots_cbk : public tools::sg::ecbk {
|
||||
@@ -802,8 +803,8 @@ protected:
|
||||
void G4ToolsSGSceneHandler::TouchPlotters(tools::sg::node& a_sg) {
|
||||
tools::sg::search_action sa(G4cout);
|
||||
const tools::sg::search_action::paths_t& paths = tools::sg::find_paths<tools::sg::plots>(sa,a_sg);
|
||||
tools_vforcit(tools::sg::path_t,paths,it) {
|
||||
tools::sg::plots* _plots = tools::sg::tail<tools::sg::plots>(*it);
|
||||
for(const auto& path : paths) {
|
||||
tools::sg::plots* _plots = tools::sg::tail<tools::sg::plots>(path);
|
||||
if(_plots) {
|
||||
SetPlotterHistograms(*_plots);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user