34
34
*/
35
35
36
36
#include " ngscopeclient.h"
37
+ #include " ../scopehal/MockOscilloscope.h"
37
38
#include " ManageInstrumentsDialog.h"
38
39
#include " MainWindow.h"
39
40
@@ -131,7 +132,9 @@ void ManageInstrumentsDialog::TriggerGroupsTable()
131
132
// If we have no scopes but are not empty, we're a trend-only group
132
133
// Show a dummy root node
133
134
bool rootOpen = false ;
135
+ bool rootIsMock = false ;
134
136
SCPIOscilloscope* firstScope = nullptr ;
137
+ MockOscilloscope* mockScope = nullptr ;
135
138
136
139
if (!group->HasScopes ())
137
140
{
@@ -148,18 +151,36 @@ void ManageInstrumentsDialog::TriggerGroupsTable()
148
151
// Normal root node
149
152
else
150
153
{
154
+ // If the first scope is a mock scope, show it differently
151
155
firstScope = dynamic_cast <SCPIOscilloscope*>(group->m_primary );
152
- if (!firstScope)
153
- LogFatal (" group has secondary but no primary, shouldn't be possible\n " );
156
+ mockScope = dynamic_cast <MockOscilloscope*>(group->m_primary );
154
157
155
- ImGui::PushID (firstScope);
156
- ImGui::TableNextRow (ImGuiTableRowFlags_None);
157
- ImGui::TableSetColumnIndex (0 );
158
+ if (mockScope)
159
+ {
160
+ ImGui::PushID (mockScope);
161
+ ImGui::TableNextRow (ImGuiTableRowFlags_None);
162
+ ImGui::TableSetColumnIndex (0 );
158
163
159
- // Display the node for the root of the trigger group
160
- rootOpen = ImGui::TreeNodeEx (
161
- group->GetDescription ().c_str (),
162
- ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_DefaultOpen );
164
+ // Display the node for the root of the trigger group
165
+ rootOpen = ImGui::TreeNodeEx (
166
+ group->GetDescription ().c_str (),
167
+ ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_DefaultOpen );
168
+
169
+ rootIsMock = true ;
170
+ }
171
+ else if (!firstScope)
172
+ LogFatal (" group has secondary but no primary, shouldn't be possible\n " );
173
+ else
174
+ {
175
+ ImGui::PushID (firstScope);
176
+ ImGui::TableNextRow (ImGuiTableRowFlags_None);
177
+ ImGui::TableSetColumnIndex (0 );
178
+
179
+ // Display the node for the root of the trigger group
180
+ rootOpen = ImGui::TreeNodeEx (
181
+ group->GetDescription ().c_str (),
182
+ ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_DefaultOpen );
183
+ }
163
184
}
164
185
165
186
// Help tooltip
@@ -175,54 +196,57 @@ void ManageInstrumentsDialog::TriggerGroupsTable()
175
196
ImGui::EndTooltip ();
176
197
}
177
198
178
- // Allow dropping
179
- if (ImGui::BeginDragDropTarget ())
199
+ if (!rootIsMock)
180
200
{
181
- auto payload = ImGui::AcceptDragDropPayload ( " TriggerGroup " , 0 );
182
- if ( (payload != nullptr ) && (payload-> DataSize == sizeof (TriggerGroupDragDescriptor)) )
201
+ // Allow dropping
202
+ if (ImGui::BeginDragDropTarget () )
183
203
{
184
- auto desc = reinterpret_cast <TriggerGroupDragDescriptor*>(payload->Data );
204
+ auto payload = ImGui::AcceptDragDropPayload (" TriggerGroup" , 0 );
205
+ if ( (payload != nullptr ) && (payload->DataSize == sizeof (TriggerGroupDragDescriptor)) )
206
+ {
207
+ auto desc = reinterpret_cast <TriggerGroupDragDescriptor*>(payload->Data );
185
208
186
- // Stop the trigger if rearranging trigger groups
187
- m_session.StopTrigger ();
209
+ // Stop the trigger if rearranging trigger groups
210
+ m_session.StopTrigger ();
188
211
189
- // Dropping from a different group
190
- if (desc->m_group != group.get ())
191
- {
192
- if (desc->m_scope )
212
+ // Dropping from a different group
213
+ if (desc->m_group != group.get ())
193
214
{
194
- group->AddSecondary (desc->m_scope );
195
- desc->m_group ->RemoveScope (desc->m_scope );
215
+ if (desc->m_scope )
216
+ {
217
+ group->AddSecondary (desc->m_scope );
218
+ desc->m_group ->RemoveScope (desc->m_scope );
219
+ }
220
+ else
221
+ {
222
+ group->AddFilter (desc->m_filter );
223
+ desc->m_group ->RemoveFilter (desc->m_filter );
224
+ }
196
225
}
226
+
227
+ // Drop from a child of this group
197
228
else
198
229
{
199
- group->AddFilter (desc->m_filter );
200
- desc->m_group ->RemoveFilter (desc->m_filter );
230
+ if (desc->m_scope )
231
+ group->MakePrimary (desc->m_scope );
232
+ // no hierarchy for filters so do nothing
201
233
}
202
234
}
203
235
204
- // Drop from a child of this group
205
- else
206
- {
207
- if (desc->m_scope )
208
- group->MakePrimary (desc->m_scope );
209
- // no hierarchy for filters so do nothing
210
- }
236
+ ImGui::EndDragDropTarget ();
211
237
}
212
238
213
- ImGui::EndDragDropTarget ();
214
- }
215
-
216
- // Allow dragging
217
- if (ImGui::BeginDragDropSource (ImGuiDragDropFlags_None))
218
- {
219
- TriggerGroupDragDescriptor desc (group.get (), firstScope, nullptr );
220
- ImGui::SetDragDropPayload (
221
- " TriggerGroup" ,
222
- &desc,
223
- sizeof (desc));
224
- ImGui::TextUnformatted (firstScope->m_nickname .c_str ());
225
- ImGui::EndDragDropSource ();
239
+ // Allow dragging
240
+ if (ImGui::BeginDragDropSource (ImGuiDragDropFlags_None))
241
+ {
242
+ TriggerGroupDragDescriptor desc (group.get (), firstScope, nullptr );
243
+ ImGui::SetDragDropPayload (
244
+ " TriggerGroup" ,
245
+ &desc,
246
+ sizeof (desc));
247
+ ImGui::TextUnformatted (firstScope->m_nickname .c_str ());
248
+ ImGui::EndDragDropSource ();
249
+ }
226
250
}
227
251
228
252
if (firstScope)
@@ -235,6 +259,16 @@ void ManageInstrumentsDialog::TriggerGroupsTable()
235
259
ImGui::TextUnformatted (firstScope->GetSerial ().c_str ());
236
260
}
237
261
262
+ else if (mockScope)
263
+ {
264
+ if (ImGui::TableSetColumnIndex (1 ))
265
+ ImGui::TextUnformatted (mockScope->GetVendor ().c_str ());
266
+ if (ImGui::TableSetColumnIndex (2 ))
267
+ ImGui::TextUnformatted (mockScope->GetName ().c_str ());
268
+ if (ImGui::TableSetColumnIndex (3 ))
269
+ ImGui::TextUnformatted (mockScope->GetSerial ().c_str ());
270
+ }
271
+
238
272
// then put all other nodes under it
239
273
if (rootOpen)
240
274
{
@@ -359,7 +393,7 @@ void ManageInstrumentsDialog::RowForNewGroup()
359
393
360
394
void ManageInstrumentsDialog::AllInstrumentsTable ()
361
395
{
362
- auto insts = m_session.GetSCPIInstruments ();
396
+ auto insts = m_session.GetInstruments ();
363
397
float width = ImGui::GetFontSize ();
364
398
ImGui::TableSetupScrollFreeze (0 , 1 ); // Header row does not scroll
365
399
ImGui::TableSetupColumn (" Nickname" , ImGuiTableColumnFlags_WidthFixed, 6 *width);
@@ -384,7 +418,7 @@ void ManageInstrumentsDialog::AllInstrumentsTable()
384
418
ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap,
385
419
ImVec2 (0 , 0 )))
386
420
{
387
- m_selection = inst;
421
+ m_selection = dynamic_cast <SCPIInstrument*>( inst) ;
388
422
rowIsSelected = true ;
389
423
}
390
424
if (ImGui::TableSetColumnIndex (1 ))
@@ -401,6 +435,9 @@ void ManageInstrumentsDialog::AllInstrumentsTable()
401
435
{
402
436
string types = " " ;
403
437
438
+ if (dynamic_cast <MockOscilloscope*>(inst) != nullptr )
439
+ types += " offline " ;
440
+
404
441
if (itype & Instrument::INST_OSCILLOSCOPE)
405
442
types += " oscilloscope " ;
406
443
if (itype & Instrument::INST_DMM)
0 commit comments