-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRopView.h
293 lines (266 loc) · 15.4 KB
/
RopView.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
#pragma once
// https://www.olympus-ims.com/en/.downloads/download/?file=285216846&fl=en_US Catalogue
// List of Documentational Notes
void Class_Relationships();
void Design_principles();
void Diagrams();
void Performance();
void Specific_FrameMouse();
void stateDiagram();
// Class Relationships
void Class_Relationships()
{
/*
Class Diagram & Design Patterns:
--------------------------------
Root
├── statuslogs (Singleton pattern)
│ ├── + getinstance()
│ └── + addLogMessage()
│
├── nFactoryFrame (Factory pattern)
│ ├── + createLogFrame()
│ └── + createGraphicsFrame()
│
├── nFrame (Composite pattern)
│ ├── + createFrame()
│ └── Inherited by:
│ ├── nLogFrame
│ │ ├── + createFrame()
│ │ └── + update()
│ └── nGraphicsFrame
│ ├── + createFrame()
│ └── + update()
│
├── UIFrame (Singleton pattern)
│ ├── + getInstance()
│ └── + mainloop()
│
├── nObserver (Observer pattern)
│ ├── + update()
│ └── Implemented by:
│ ├── nLogFrame
│ └── nGraphicsFrame
│
└── ObserverMgr (Observer pattern)
├── nSubject
│ ├── + addObserver(nObserver)
│ └── + notify()
└── Notifies Observers:
├── nLogFrame
└── nGraphicsFrame
Sequence Diagram:
-----------------
Root
├── Program Start
│ ├── MainLoop calls UIFrame
│ │ └── UIFrame creates frames via nFactoryFrame
│ │ ├── createLogFrame()
│ │ │ └── nLogFrame created
│ │ └── createGraphicsFrame()
│ │ └── nGraphicsFrame created
│ └── UIFrame calls notify() on nSubject
│
├── Notification Phase
│ ├── nSubject notifies:
│ │ ├── nLogFrame
│ │ │ └── nLogFrame calls update()
│ │ └── nGraphicsFrame
│ │ └── nGraphicsFrame calls update()
│
└── Observers Update
├── nLogFrame updates display
└── nGraphicsFrame updates display
*/
}
// Design Patterns & Principles
void Design_principles()
{
/*
+----------------------------------+ +----------------------------------+
| mainwindow (UIFrame) | | ObserverMgr |
|----------------------------------| |----------------------------------|
| +getInstance(): UIFrame |<----->| +notify(x,y,z): void |
| +mainloop(): int | | +addObserver(nObserver): void |
| +refreshxyz(x,y,z): void | +----------------------------------+
| +logical(nFrame*): void |
| +receiveData(): void |
| +sendDataToProcessor(): void |
+----------------------------------+
| ^ +----------------------------------+
| | | AscanProcessor |
| | |----------------------------------|
|<----------+--------------->| +analyze(nFrame*): bool |
v | +processData(): void |
+-------------------+----+ +----------------------------------+
| FactoryMgr |
|-------------------------| +----------------------------+
| +LogFrame() | nFrame |
| +GraphicsFrame() |----------------------------|
| +BscanFrame() | +CreateColorPalette(): void|
+-----------------------------------------| +setScandat(): void |
+----------------------------+
^ ^ ^ ^ ^
| | | | |
+---------------+--+ +--+-----------+-------+ +----+-------+-----+
| nLogFrame | | CscanFrame (nFrame) | | BscanFrame (nFrame)|
|-------------------| |----------------------| |--------------------|
| +createFrame(): QWidget| +createFrame(): QWidget| +createFrame(): QWidget|
| +update(): void | +update(): void | +update(): void |
+----------------------- +----------------------- +----------------------+
*/
}
// Class Diagram & Design Patterns
void Diagrams()
{
/*
--------------------------------
+-----------------+ +--------------------------+ +--------------------+
| statuslogs | | nFactoryFrame | | nFrame |
|-----------------| |------------------------- | |--------------------|
| + getinstance() |<-- Singleton | + createLogFrame() |<-- Factory | + createFrame() |<-- Composite
| + addLogMessage | | + createGraphicsFrame() | | |
+-----------------+ +--------------------------+ +--------------------+
^ / \
| / \
| / \
+----------------------+ +--------------------+ +----------------------+
| UIFrame | | nLogFrame | | nGraphicsFrame |
|----------------------| |--------------------| |----------------------|
| + getInstance() |<-- Singleton | + createFrame() | | + createFrame() |
| + mainloop() | | + update() | | + update() |
+----------------------+ +--------------------+ +----------------------+
| |
Implements Observer Implements Observer
|
+---------------------+
| nObserver |
|---------------------|
| + update() |
+---------------------+
ObserverMgr:
+-----------------------------------+
| nSubject (ObserverMgr) |
|-----------------------------------|
| + addObserver(nObserver) |
| + notify() |
+-----------------------------------+
|
Notifies Observers
|
+--------------------------+
| |
+--------------------+ +----------------------+
| nLogFrame | | nGraphicsFrame |
+--------------------+ +----------------------+
Sequence Diagram:
-----------------
1. Program Start:
+--------------+ +----------------+ +----------------------+ +----------------------+
| MainLoop | | UIFrame | | nFactoryFrame | | nLogFrame |
+--------------+ +----------------+ +----------------------+ +----------------------+
| | | |
| | createLogFrame() | |
| +------------------------>+ |
| | +--------------------------->+
| | | |
| | createGraphicsFrame()| |
| +------------------------>+ |
| | +--------------------------->+
| | | |
|------------------- notify() --------------------------------------------------->
2. nLogFrame and nGraphicsFrame are updated:
+--------------------+ +----------------------+ +----------------------+
| nSubject | | nLogFrame | | nGraphicsFrame |
+--------------------+ +----------------------+ +----------------------+
| | |
|------ notifyObservers() --+ |
| |------- update() --------------+
| | |-------- update() -----+
*/
}
void stateDiagram()
{
/*
[Initial State] ----------------------> [Waiting for Update]
| (notify() called)
v
[Receiving Data from nSubject]
|
v
[Processing Data in nLogFrame]
|
v
[Update nGraphicsFrame]
|
v
[Rendering Graphics in nGraphicsFrame]
|
v
[Return to Waiting for Update State]
(notify() called or data change detected)
---------------------------------------------------------
Error State:
- If data processing or rendering fails, transition to
[Error State] and log the issue using StatusLogs.
}
*/
}
void Performance()
{
/*
Performance Considerations:
1. CPU-GPU Workload Division:
- CUDA for compute-heavy tasks
- Vulkan for render-heavy tasks (e.g., 3D rendering).
- Ensure asynchronous data transfer between CPU and GPU.
2. CUDA-Vulkan Interop:
- Use CUDA-Vulkan Interop to share resources directly (zero-copy).
- Avoid data transfer overhead with mapped memory.
3. GPU Memory Management:
- Use Unified Memory to share data between CPU and GPU.
- Implement memory pooling in Vulkan to reduce memory allocation overhead.
4. Render Pipeline Optimization:
- Prebuild Vulkan pipeline state objects (PSO) for faster execution.
- Reuse command buffers and descriptor sets to minimize setup cost.
5. Scalability:
- Use Dynamic Level of Detail (LOD) to reduce polygon count.
- Implement Frustum Culling to avoid rendering unnecessary objects.
- Take advantage of Vulkan’s multithreading for parallel rendering.
6. Real-time Rendering:
- Employ Vulkan async compute to handle continuous data streams.
- Reduce latency with low-latency rendering (reduce buffer and queue depth).
7. Error Handling:
- Use cudaGetLastError() for error checks in CUDA.
- Enable Vulkan Validation Layers to catch runtime issues.
*/
}
// specific Observer Pattern, Factory Pattern & Mouse Event Handling
void Specific_FrameMouse()
{
/*
Observer Pattern - Core Mechanism for Frame Updates: The observer pattern ensures that when an event (like a mouse click) occurs, the observer notifies all relevant frames
(Ascan, Bscan, Cscan). This ensures synchronization across different views without direct dependencies between them.
[Main Frame] --> [Observer] --> [Ascan Frame]
|--> [Bscan Frame]
|--> [Cscan Frame]
Mouse Event Handling in ZoomableGraphicsView
[ZoomableGraphicsView]
|--> Left Click: Triggers observer to update all frames
|--> Left + Drag: Frame-specific updates, skipping local frame for efficiency
|--> Middle Click: Activates panning mode
Left Click: Calls the observer to refresh all frames.
Left Drag: The current frame does not refresh to save resources, while other frames are notified to update based on isPanning status.
Middle Click (Panning): Allows users to navigate the frame without modifying the content.
Display Mouse Position with Tooltip: Whenever the mouse moves, the current position (X, Y, Z) is displayed in a tooltip
[Mouse Move Event] --> [Tooltip Display] --> X, Y, Z Coordinates Shown
Distinguishing Local and Global Panning States
[isPanning - Global State] --> Manages updates across frames
[isLocalPanning - Local State] --> Manages updates within the current frame
Factory Pattern - Creating and Managing Frames: Using the factory pattern, each frame (Ascan, Bscan, Cscan) is created in a modular and extensible manner
[UIManager] --> [Factory] --> [Ascan, Bscan, Cscan Frames]
Menu and Settings Management: A settings dialog is accessed via the menu bar, allowing users to adjust system settings such as resolution or toggling the Cscan layer
[MenuBar] --> [Settings Dialog] --> Modify Resolution, Cscan Layer
*/
}