diff --git a/opossum/src/analyzers/ghostfocus.rs b/opossum/src/analyzers/ghostfocus.rs index 59485bdc31264b07055f0b9f4adb9d657b9dc3b0..4ee2df3e72abebcc2bd0ce41eb39409addf179d3 100644 --- a/opossum/src/analyzers/ghostfocus.rs +++ b/opossum/src/analyzers/ghostfocus.rs @@ -115,8 +115,9 @@ impl Analyzer for GhostFocusAnalyzer { let proptype = Proptype::from(ghost_focus_history); props.create("propagation", "ray propagation", None, proptype)?; - let node_report = + let mut node_report = NodeReport::new("ray propagation", "Global ray propagation", "global", props); + node_report.set_show_item(true); analysis_report.add_node_report(node_report); for node in scenery.graph().nodes() { let node_name = &node.optical_ref.borrow().name(); diff --git a/opossum/src/html/html_report.html b/opossum/src/html/html_report.html index fd33f141eef2351c64eda897ff293a72969fd897..72423c8bfbda67f6b6bda719f5c3da997032e92e 100644 --- a/opossum/src/html/html_report.html +++ b/opossum/src/html/html_report.html @@ -1,50 +1,57 @@ <!DOCTYPE html> <html class="h-100" lang="en"> - <head> - <meta charset="UTF-8" /> - <meta name="description" content="OPOSSUM Analysis Report" /> - <meta name="keywords" content="OPOSSUM,Laser,Simulation,Optics" /> - <meta name="author" content="Udo Eisenbarth" /> - <meta http-equiv="X-UA-Compatible" content="IE=edge" /> - <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> - <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"> - <title>OPOSSUM Analysis Report</title> - </head> - <body class="d-flex flex-column h-100"> - <main class="flex-shrink-0" role="main"> - <div class="container justify-content-center"> - <div class="row"> - <div class="col"> - <div class="mx-auto p-2" style="width: 150px;"> - <img src="Logo_square.svg" class="img-fluid" alt="OPOSSUM"/> - </div> + +<head> + <meta charset="UTF-8" /> + <meta name="description" content="OPOSSUM Analysis Report" /> + <meta name="keywords" content="OPOSSUM,Laser,Simulation,Optics" /> + <meta name="author" content="Udo Eisenbarth" /> + <meta http-equiv="X-UA-Compatible" content="IE=edge" /> + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> + <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"> + <title>OPOSSUM Analysis Report</title> +</head> + +<body class="d-flex flex-column"> + <main class="flex-shrink-0" role="main"> + <div class="container justify-content-center"> + <div class="row"> + <div class="col"> + <div class="mx-auto p-2" style="width: 150px;"> + <img src="Logo_square.svg" class="img-fluid" alt="OPOSSUM" /> </div> </div> - <div class="row"> - <div class="col"> - <h1 class="text-center">{analysis_type} Report</h1> - </div> + </div> + <div class="row"> + <div class="col"> + <h1 class="text-center">{analysis_type} Report</h1> </div> - <div class="row"> - <div class="col-md-6 text-start"> - <span class="small">OPOSSUM version: {opossum_version}</span> - </div> - <div class="col-md-6 text-end"> - <span class="small">Analysis date: {analysis_timestamp}</span> - </div> + </div> + <div class="row"> + <div class="col-md-6 text-start"> + <span class="small">OPOSSUM version: {opossum_version}</span> + </div> + <div class="col-md-6 text-end"> + <span class="small">Analysis date: {analysis_timestamp}</span> </div> - <hr/> - <div class="row"> - <div class="col"> - <h3>{description}</h3> - <div class="text-center"> - <img src="scenery.svg" class="img-fluid" style="max-height: 600pt;" alt="Optical scene diagram"/> - </div> + </div> + <hr /> + <div class="row"> + <div class="col"> + <h3>{description}</h3> + <div class="text-center"> + <img src="scenery.svg" class="img-fluid" style="max-height: 600pt; break-after:all;" + alt="Optical scene diagram" /> </div> </div> + </div> + <div class="accordion" id="nodeAccordion"> {{ for node_report in node_reports}}{{ call node_report with node_report }}{{ endfor }} </div> - </main> - <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script> - </body> + </div> + </main> + <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script> + +</body> + </html> \ No newline at end of file diff --git a/opossum/src/html/node_report.html b/opossum/src/html/node_report.html index ca40378d53795ded76dc1fc2b92ae4e448a50753..d35e64cc30398157da070a3065166a78a6110fd0 100644 --- a/opossum/src/html/node_report.html +++ b/opossum/src/html/node_report.html @@ -1,19 +1,19 @@ -<div class="row mb-1"> - <div class="col"> - <div class="card"> - <div class="card-header"> - <span class="h5">{node_name}</span> <small class="muted">{node_type}</small> - </div> - <div class="card-body"> - <table class="table table-sm table-bordered"> - <tbody> - {{for property in props}}<tr> - <th class="text-end" scope="row" style="width:20ch"><abbr title="{property.description}">{property.name}</abbr>:</th> - <td style="width:auto">{property.prop_value | unescaped}</td> - </tr>{{ endfor }} - </tbody> - </table> - </div> +<div class="accordion-item"> + <h5 class="accordion-header"> + <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#{uuid}"> + <span class="h5 me-2">{node_name}</span><small class="muted">{node_type}</small> + </button> + </h5> + <div id="{uuid}" class="accordion-collapse collapse {{ if show_item }}show{{ endif }}"> + <div class="accordion-body"> + <table class="table table-sm table-bordered"> + <tbody> + {{for property in props}}<tr> + <th class="text-end" scope="row" style="width:20ch"><abbr title="{property.description}">{property.name}</abbr>:</th> + <td style="width:auto">{property.prop_value | unescaped}</td> + </tr>{{ endfor }} + </tbody> + </table> </div> </div> -</div> \ No newline at end of file +</div> diff --git a/opossum/src/nodes/node_group/mod.rs b/opossum/src/nodes/node_group/mod.rs index 7432ac8bb26ae5d7d11205aadaf3d177987b1f96..e159827a2b9ed9b4f0c52a7c8666a67ac35d20ee 100644 --- a/opossum/src/nodes/node_group/mod.rs +++ b/opossum/src/nodes/node_group/mod.rs @@ -21,6 +21,7 @@ use crate::{ SceneryResources, }; use chrono::Local; +use num::Zero; pub use optic_graph::OpticGraph; use petgraph::prelude::NodeIndex; use serde::{Deserialize, Serialize}; @@ -352,10 +353,15 @@ impl NodeGroup { pub fn toplevel_report(&self) -> OpmResult<AnalysisReport> { let mut analysis_report = AnalysisReport::new(get_version(), Local::now()); analysis_report.add_scenery(self); + let mut section_number: usize = 0; for node in self.graph.nodes() { let uuid = node.uuid().as_simple().to_string(); - if let Some(node_report) = node.optical_ref.borrow().node_report(&uuid) { + if let Some(mut node_report) = node.optical_ref.borrow().node_report(&uuid) { + if section_number.is_zero() { + node_report.set_show_item(true); + } analysis_report.add_node_report(node_report); + section_number += 1; } } Ok(analysis_report) diff --git a/opossum/src/properties/proptype.rs b/opossum/src/properties/proptype.rs index d8e7efd66dc563b0d32e1d9700d85542b49ed2d2..911e742762be7e7ad8613ff150e085c81a9b2a25 100644 --- a/opossum/src/properties/proptype.rs +++ b/opossum/src/properties/proptype.rs @@ -155,6 +155,7 @@ impl Proptype { report.uuid() )), uuid: report.uuid().to_string(), + show_item: report.show_item(), }; tt.render("group", &html_node_report) } diff --git a/opossum/src/reporting/html_report.rs b/opossum/src/reporting/html_report.rs index 0e87d48f4fe386b0cc7cd3abeac9c177bf576c28..c91082f95bdc5eb1b33914e1f5269ae6ce1c9b05 100644 --- a/opossum/src/reporting/html_report.rs +++ b/opossum/src/reporting/html_report.rs @@ -67,6 +67,8 @@ pub struct HtmlNodeReport { pub props: Vec<HtmlProperty>, /// uuid of the node (needed for constructing filenames) pub uuid: String, + /// show or hide item in report by default + pub show_item: bool, } #[derive(Serialize)] diff --git a/opossum/src/reporting/node_report.rs b/opossum/src/reporting/node_report.rs index 73f1aa34eb5405237d1bf4f7623ae7a5171b69cb..56b42f0943c7e0cfa6ccd66b15d952ce7d678683 100644 --- a/opossum/src/reporting/node_report.rs +++ b/opossum/src/reporting/node_report.rs @@ -16,6 +16,7 @@ pub struct NodeReport { name: String, uuid: String, properties: Properties, + show_item: bool, } impl NodeReport { /// Creates a new [`NodeReport`]. @@ -26,6 +27,7 @@ impl NodeReport { name: name.to_owned(), uuid: uuid.to_string(), properties, + show_item: false, } } /// Returns a reference to the node type of this [`NodeReport`]. @@ -53,6 +55,7 @@ impl NodeReport { .properties .html_props(&format!("{id}_{}_{}", self.name, self.uuid)), uuid: self.uuid.clone(), + show_item: self.show_item, } } /// Returns a reference to the uuid of this [`NodeReport`]. @@ -69,6 +72,13 @@ impl NodeReport { self.properties .export_data(report_path, &format!("{id}_{}_{}", &self.name, &self.uuid)) } + #[must_use] + pub const fn show_item(&self) -> bool { + self.show_item + } + pub fn set_show_item(&mut self, show_item: bool) { + self.show_item = show_item; + } } impl From<NodeReport> for Proptype {