Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 33 additions & 8 deletions src/ngscopeclient/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1283,14 +1283,39 @@ void MainWindow::DockingArea()
}
ImGui::DockBuilderDockWindow(group->GetID().c_str(), node->ID);

//Add a new waveform area for our stream to the new group
LogTrace("Making new area for %s in %s\n",
request.m_stream.GetName().c_str(),
group->GetID().c_str());
auto area = make_shared<WaveformArea>(request.m_stream, group, this);
if(request.m_ramp != "")
area->GetDisplayedChannel(0)->m_colorRamp = request.m_ramp;
group->AddArea(area);
//Add a new waveform area for our stream/streamGroup to the new group
if(request.m_stream)
{
LogTrace("Making new area for %s in %s\n",
request.m_stream.GetName().c_str(),
group->GetID().c_str());
auto area = make_shared<WaveformArea>(request.m_stream, group, this);
if(request.m_ramp != "")
area->GetDisplayedChannel(0)->m_colorRamp = request.m_ramp;
group->AddArea(area);
}
else if(request.m_streamGroup)
{
std::shared_ptr<WaveformArea> area;
bool first = true;
for(auto channel : request.m_streamGroup->m_channels)
{
StreamDescriptor s(channel, 0);
LogTrace("Making new area for %s in %s\n",
s.GetName().c_str(),
group->GetID().c_str());
if(first || !request.m_singleArea)
{
area = make_shared<WaveformArea>(s, group, this);
group->AddArea(area);
first = false;
}
else
{
area->AddStream(s);
}
}
}
}

//Finish up
Expand Down
56 changes: 50 additions & 6 deletions src/ngscopeclient/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,30 +70,68 @@ class SplitGroupRequest
, m_direction(direction)
, m_stream(stream)
, m_ramp(ramp)
, m_streamGroup(nullptr)
{
auto schan = dynamic_cast<OscilloscopeChannel*>(stream.m_channel);
if(schan)
schan->AddRef();
}

SplitGroupRequest(std::shared_ptr<WaveformGroup> group, ImGuiDir direction, std::shared_ptr<StreamGroupDescriptor> streamGroup, bool singleArea)
: m_group(group)
, m_direction(direction)
, m_streamGroup(streamGroup)
, m_singleArea(singleArea)
{
if(streamGroup)
{
for(auto chan : streamGroup->m_channels)
{
chan->AddRef();
}
}
}

SplitGroupRequest(const SplitGroupRequest& rhs)
: m_group(rhs.m_group)
, m_direction(rhs.m_direction)
, m_stream(rhs.m_stream)
, m_ramp(rhs.m_ramp)
, m_streamGroup(rhs.m_streamGroup)
, m_singleArea(rhs.m_singleArea)
{
auto schan = dynamic_cast<OscilloscopeChannel*>(rhs.m_stream.m_channel);
if(schan)
schan->AddRef();
if(rhs.m_stream)
{
auto schan = dynamic_cast<OscilloscopeChannel*>(rhs.m_stream.m_channel);
if(schan)
schan->AddRef();
}
else if(rhs.m_streamGroup)
{
for(auto chan : rhs.m_streamGroup->m_channels)
{
chan->AddRef();
}
}
}

SplitGroupRequest& operator=(const SplitGroupRequest& /*rhs*/) =delete;

~SplitGroupRequest()
{
auto schan = dynamic_cast<OscilloscopeChannel*>(m_stream.m_channel);
if(schan)
schan->Release();
if(m_stream)
{
auto schan = dynamic_cast<OscilloscopeChannel*>(m_stream.m_channel);
if(schan)
schan->Release();
}
else if(m_streamGroup)
{
for(auto chan : m_streamGroup->m_channels)
{
chan->Release();
}
}
}

std::shared_ptr<WaveformGroup> m_group;
Expand All @@ -102,6 +140,9 @@ class SplitGroupRequest

///@brief Color ramp request (may be blank if unspecified)
std::string m_ramp;

std::shared_ptr<StreamGroupDescriptor> m_streamGroup;
bool m_singleArea;
};

/**
Expand Down Expand Up @@ -142,6 +183,9 @@ class MainWindow : public VulkanWindow
std::string colorRamp)
{ m_splitRequests.push_back(SplitGroupRequest(group, direction, stream, colorRamp)); }

void QueueSplitGroup(std::shared_ptr<WaveformGroup> group, ImGuiDir direction, std::shared_ptr<StreamGroupDescriptor> streamGroup, bool singleArea)
{ m_splitRequests.push_back(SplitGroupRequest(group, direction, streamGroup, singleArea)); }

void ShowChannelProperties(OscilloscopeChannel* channel);
void ShowInstrumentProperties(std::shared_ptr<Instrument> instrument);
void ShowTriggerProperties();
Expand Down
122 changes: 112 additions & 10 deletions src/ngscopeclient/StreamBrowserDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,10 @@ bool StreamBrowserDialog::renderOnOffToggle(const char* label, bool alignRight,
@param inst the instrument to render the progress channel for
@param chan the channel to render the progress for
@param isLast true if it is the last channel of the instrument

@return Returns true if the progress bar has been rendered
*/
void StreamBrowserDialog::renderDownloadProgress(std::shared_ptr<Instrument> inst, InstrumentChannel *chan, bool isLast)
bool StreamBrowserDialog::renderDownloadProgress(std::shared_ptr<Instrument> inst, InstrumentChannel *chan, bool isLast)
{
static const char* const download[] = {"DOWNLOADING", "DOWNLOAD" ,"DL","D", NULL};

Expand Down Expand Up @@ -516,7 +518,7 @@ void StreamBrowserDialog::renderDownloadProgress(std::shared_ptr<Instrument> ins
}

if (!shouldRender)
return;
return false;

/// @brief Width used to display progress bars (e.g. download progress bar)
#define PROGRESS_BAR_WIDTH 80
Expand Down Expand Up @@ -548,10 +550,11 @@ void StreamBrowserDialog::renderDownloadProgress(std::shared_ptr<Instrument> ins
ImGui::ProgressBar(chan->GetDownloadProgress(), ImVec2(PROGRESS_BAR_WIDTH, ImGui::GetFontSize()));
}

return;
return true;
}
}
// well, shoot -- I guess there wasn't enough room to do *anything* useful!
return true;
}

/**
Expand Down Expand Up @@ -1058,10 +1061,11 @@ void StreamBrowserDialog::renderInstrumentNode(shared_ptr<Instrument> instrument
}
}
bool result;
bool changed;
if(allOn || someOn)
{
result = true;
renderToggle(
changed = renderToggle(
"###psuon",
true,
allOn ?
Expand All @@ -1071,9 +1075,9 @@ void StreamBrowserDialog::renderInstrumentNode(shared_ptr<Instrument> instrument
else
{
result = false;
renderOnOffToggle("###psuon", true, result);
changed = renderOnOffToggle("###psuon", true, result);
}
if(result != allOn)
if(changed)
{
if(psu->SupportsMasterOutputSwitching())
psu->SetMasterPowerEnable(result);
Expand Down Expand Up @@ -1135,12 +1139,74 @@ void StreamBrowserDialog::renderInstrumentNode(shared_ptr<Instrument> instrument
renderChannelNode(instrument,i,(i == lastEnabledChannelIndex));
}
int bankNumber = 1;
bool bankIsOpen;
for(auto bank : digitalBanks)
{ // Iterate on digital banks
if(bank.size() > 1)
{ // Only show Digital Bank node if there is more than on channel in the bank
string nodeName = "Digital Bank " + to_string(bankNumber);
if(ImGui::TreeNodeEx(nodeName.c_str()))
bankIsOpen = ImGui::TreeNodeEx(nodeName.c_str());

// Add dragdrop source for this bank
if(ImGui::BeginDragDropSource())
{
m_streamGroupDesciptor = make_shared<StreamGroupDescriptor>(nodeName, bank);
auto ptr = m_streamGroupDesciptor.get();
ImGui::SetDragDropPayload("StreamGroup", &ptr, sizeof(m_streamGroupDesciptor));
ImGui::TextUnformatted(m_streamGroupDesciptor->GetName().c_str());
ImGui::EndDragDropSource();
}
else
DoItemHelp();
/* Currently, enable/disable state is coupled to node reference counting, so we can't let the user manually enable/disable channels
// Add Banck on/off toggle
startBadgeLine();
bool allOn = true;
bool someOn = false;
for(auto channel : bank)
{ // Iterate on bank's channel
size_t i = channel->GetIndex();
if(scope->IsChannelEnabled(i))
{
someOn = true;
}
else
{
allOn = false;
}
}
bool result;
bool changed;
string toggleId = "###"+nodeName+"on";
if(allOn || someOn)
{
result = true;
changed = renderToggle(
toggleId.c_str(),
true,
allOn ?
ImGui::ColorConvertU32ToFloat4(prefs.GetColor("Appearance.Stream Browser.instrument_on_badge_color")) :
ImGui::ColorConvertU32ToFloat4(prefs.GetColor("Appearance.Stream Browser.instrument_partial_badge_color")), result,"DISABLE","ENABLED",3);
}
else
{
result = false;
changed = renderToggle(
toggleId.c_str(),
true,
ImGui::ColorConvertU32ToFloat4(prefs.GetColor("Appearance.Stream Browser.instrument_off_badge_color")),
result,"DISABLED","ENABLE",3);
}
if(changed)
{
for(auto channel : bank)
{ // Iterate on bank's channel
size_t i = channel->GetIndex();
result ? scope->EnableChannel(i) : scope->DisableChannel(i);
}
}
*/
if(bankIsOpen)
{
ImGui::Unindent(ImGui::GetTreeNodeToLabelSpacing());
for(auto channel : bank)
Expand Down Expand Up @@ -1525,17 +1591,53 @@ void StreamBrowserDialog::renderChannelNode(shared_ptr<Instrument> instrument, s
startBadgeLine();
if (scopechan)
{
bool chanEnabled = scopechan->IsEnabled();

//"trigger" badge on trigger inputs to show they're not displayable channels
if(scopechan->GetType(0) == Stream::STREAM_TYPE_TRIGGER)
renderBadge(ImGui::ColorConvertU32ToFloat4(prefs.GetColor("Appearance.Stream Browser.instrument_disabled_badge_color")), "TRIG ONLY", "TRIG","--", nullptr);

/* Currently, enable/disable state is coupled to node reference counting, so we can't let the user manually enable/disable channels
// Scope channel
else if (!scopechan->IsEnabled())
renderBadge(ImGui::ColorConvertU32ToFloat4(prefs.GetColor("Appearance.Stream Browser.instrument_disabled_badge_color")), "DISABLED", "DISA","--", nullptr);
else if (!chanEnabled)
{
if(renderToggle(
"###scopeChanEnable",
true,
ImGui::ColorConvertU32ToFloat4(prefs.GetColor("Appearance.Stream Browser.instrument_disabled_badge_color")),
chanEnabled,
"DISABLED",
"ENABLE",
3))
{
if(chanEnabled)
scope->EnableChannel(channelIndex);
}
//renderBadge(ImGui::ColorConvertU32ToFloat4(prefs.GetColor("Appearance.Stream Browser.instrument_disabled_badge_color")), "DISABLED", "DISA","--", nullptr);
}
*/

//Download in progress
else
renderDownloadProgress(instrument, channel, isLast);
{
if(!renderDownloadProgress(instrument, channel, isLast))
{ // No download in progress, we can show the ENABLE/DISABLE toggle
/* Currently, enable/disable state is coupled to node reference counting, so we can't let the user manually enable/disable channels
if(renderToggle(
"###scopeChanEnable",
true,
ImGui::ColorConvertU32ToFloat4(prefs.GetColor("Appearance.Stream Browser.instrument_on_badge_color")),
chanEnabled,
"DISABLE",
"ENABLED",
3))
{
if(!chanEnabled)
scope->DisableChannel(channelIndex);
}
*/
}
}
}
else if(psu)
{
Expand Down
5 changes: 4 additions & 1 deletion src/ngscopeclient/StreamBrowserDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class StreamBrowserDialog : public Dialog
uint8_t cropTextTo = 0,
float paddingRight = 0);
bool renderOnOffToggle(const char* label, bool alignRight, bool& curValue, const char* valueOff = "OFF", const char* valueOn = "ON", uint8_t cropTextTo = 0, float paddingRight = 0);
void renderDownloadProgress(std::shared_ptr<Instrument> inst, InstrumentChannel *chan, bool isLast);
bool renderDownloadProgress(std::shared_ptr<Instrument> inst, InstrumentChannel *chan, bool isLast);
bool renderPsuRows(bool isVoltage, bool cc, PowerSupplyChannel* chan, std::string& currentValue, float& committedValue, std::string& measuredValue, bool &clicked, bool &hovered);
void renderAwgProperties(std::shared_ptr<FunctionGenerator> awg, FunctionGeneratorChannel* awgchan);
void renderDmmProperties(std::shared_ptr<Multimeter> dmm, MultimeterChannel* dmmchan, bool isMain, bool &clicked, bool &hovered);
Expand Down Expand Up @@ -189,6 +189,9 @@ class StreamBrowserDialog : public Dialog
///@brief Map of instruments to timebase settings
std::map<std::shared_ptr<Instrument>, std::shared_ptr<StreamBrowserTimebaseInfo> > m_timebaseConfig;

///@brief Reference to currently dragged StreamGroupDesciptor
std::shared_ptr<StreamGroupDescriptor> m_streamGroupDesciptor;

///@brief Helper to render a small button that's non-interactive
void SmallDisabledButton(const char* label)
{
Expand Down
Loading
Loading