Skip to content

Commit 7db78df

Browse files
committed
Add comments to view system
1 parent b3f224e commit 7db78df

9 files changed

Lines changed: 36 additions & 3 deletions

File tree

doc/technical_overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ The [main app](/src/app.rs#L19) consists of the [high level
4444
`Pipeline`](#high-level-pipeline), the [pipelines execution
4545
system](#execution-of-the-pipeline) and the [pipelines editing
4646
state](#editing-of-the-pipeline). As well as a
47-
[`DataViewsState`](/src/view/mod.rs#L25), a
48-
[`DataViewsManager`](/src/view/views_manager.rs#L62) and a
49-
[`ViewsExecutor`](/src/view/execution/executor.rs#L21). It also stores the
47+
[`DataViewsState`](/src/view/mod.rs#L32), a
48+
[`DataViewsManager`](/src/view/views_manager.rs#L64) and a
49+
[`ViewsExecutor`](/src/view/execution/executor.rs#L25). It also stores the
5050
global [`DockState`](/src/gui/dock_state.rs#L18) and provides a
5151
[`Cache`](/src/cache.rs#L14).
5252

src/view/execution/executor.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ use super::DynDataViewTask;
1818

1919
// MARK: ViewsExecutor
2020

21+
/// Execution system for data view tasks, described by [super::DataViewTask].
22+
///
23+
/// Analog to the pipelines execution system. Tasks in this system can connect
24+
/// to tasks in the pipelines execution system.
2125
pub struct ViewsExecutor {
2226
runners: HashMap<ViewId, ViewTaskRunner>,
2327
}

src/view/execution/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ use crate::{
99

1010
use super::views::{DataView, DynDataView};
1111

12+
/// Describes a data view task.
13+
///
14+
/// A data view task connects into the pipelines execution system and is
15+
/// responsible for acquiring data to be rendered inside the view. Since it is
16+
/// run in a concurrent context, it should also handle all operations on the
17+
/// data that are required for rendering.
1218
pub trait DataViewTask: Send + Sync + 'static {
1319
type InputId: From<InputId> + Into<InputId>;
1420
type DataView: DataView;
@@ -28,6 +34,8 @@ pub trait DataViewTask: Send + Sync + 'static {
2834
fn run(&mut self) -> impl Future<Output = anyhow::Result<()>> + Send;
2935
}
3036

37+
/// Dynamic version of [DataViewTask]. This trait is implemented automatically
38+
/// for all types implementing [DataViewTask] and can be used as a trait object.
3139
pub trait DynDataViewTask: Send + Sync {
3240
fn sync_view(&mut self, node: &dyn DynDataView);
3341

src/view/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ impl Into<usize> for ViewId {
2222
}
2323
}
2424

25+
/// High level description of data views and their connections into the
26+
/// pipeline.
27+
///
28+
/// Data views are analog to pipeline nodes, with the main difference that they
29+
/// render into their own tab. They are very similar to pipeline nodes, but have
30+
/// their own management system and execution system. They can connect into the
31+
/// pipeline.
2532
pub struct DataViewsState {
2633
views: HashMap<ViewId, Box<dyn DynDataView>>,
2734
}

src/view/views/data_vector.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct View {
1414
data_rx: Option<watch::Receiver<Option<Arc<DataVector>>>>,
1515
}
1616

17+
/// Renders a plot of a [DataVector].
1718
impl DataView for View {
1819
type InputId = InputIdSingle;
1920

src/view/views/m_scan.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ impl_enum_from_into_id_types!(InputId, [graph::InputId], {
3939

4040
// MARK: View
4141

42+
/// Renders M scans in three different perspectives.
43+
///
44+
/// Each M scan gets fully uploaded to the GPU. The different perspectives are
45+
/// achieved by sampling the scan data in a specific way on the GPU.
4246
pub struct View {
4347
m_scan: NodeOutput,
4448
b_scan_segmentation: Option<NodeOutput>,

src/view/views/mesh.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use super::prelude::*;
1212

1313
// MARK: View
1414

15+
/// Renders a [types::LumenMesh].
1516
#[derive(Clone, Debug)]
1617
pub struct View {
1718
mesh: NodeOutput,

src/view/views/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ pub enum Existence {
4545
Keep,
4646
}
4747

48+
/// Describes a data view.
49+
///
50+
/// Data views are rendered in their own tab and can connect to multiple nodes
51+
/// in the pipeline. The implementer is responsible for rendering the view.
4852
pub trait DataView: Send + Sync + Clone + 'static {
4953
type InputId: From<InputId> + Into<InputId>;
5054

@@ -80,6 +84,8 @@ pub trait DataView: Send + Sync + Clone + 'static {
8084
fn ui(&mut self, ui: &mut egui::Ui);
8185
}
8286

87+
/// Dynamic version of [DataView]. This trait is implemented automatically for
88+
/// all types implementing [DataView] and can be used as a trait object.
8389
pub trait DynDataView: Send + Sync + 'static {
8490
fn as_any(&self) -> &dyn any::Any;
8591

src/view/views_manager.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ impl<'a> DataViewsManagerBuilder<'a> {
5959
}
6060
}
6161

62+
/// Creates, removes and changes data views inside a [DataViewsState] in
63+
/// response to user interactions.
6264
pub struct DataViewsManager {
6365
view_factories: Vec<
6466
Box<dyn Fn(&NodeOutput, &Pipeline, &Cache, &RenderState) -> Option<Box<dyn DynDataView>>>,

0 commit comments

Comments
 (0)