How do you display rapidly updating data to the user in a win32 GUI app? - c++

So im building a basic win32 GUI app and I have a vector of data that gets constantly updated through an external source via a port. Im interested in displaying that list of data to the user but im not sure the best approach to go about it without causing update flickering.
I originally had an edit box in which I build a string with the information and update the window. But it has proved troublesome as the amount of data grows since I cant scroll down to look at additional data. Any ideas?

My idea is no point of updating the visual control as the same speed you receive the data. Because even-though you update at the same speed the users cannot see that change at the speed of data receiving. Human eye does not see a change happening in speed as 1/8th of a second. So better to update the visual control in a controlled manner. Maybe using a timer.

Appending to the text of an edit control for each subsequent data point will lead to flickering as the whole control re-renders as the text has changed.
I'd advise one of the following options:
1) use a ListBox or ListView control; when you add another row item, it only re-draws the new/changed/scrolled item. https://learn.microsoft.com/en-us/windows/desktop/controls/create-a-simple-list-box and https://learn.microsoft.com/en-us/windows/desktop/controls/list-view-controls-overview
2) If you only want an always-scrolling list of data, consider just having a command-line application that writes to the standard output and saves you a lot of trouble - cout or printf your data.

You can also use EM_SETSEL and EM_SCROLLCARET to automatically scroll, but also check the position of the scroll bar before doing that. If not at the bottom, it means that the user wanted to pause, so you can scroll.
Also, you can have the scroll lock key checked in order whether to scroll or not, after all that is what it's name is supposed to do.

Related

How to build an advanced link in draw.io

I am looking for how you can build a link in draw io, so that when you click first, it hides a layer and then opens a different page of the same draw io document.
so far i tried this:
data:action/json,{"actions":[{"toggle": {"cells": ["SvuciECQg7tZUCU10AH1-3"]}},{"open": "data:page/id,IZEQzf0yfGXm-2QJ5-Q8"}]}
But it seems that the Toggle is executed after the Open, and I need the Toggle to be first and then the Open.
I even tried to do an Open of the same page I'm on, do the Toggle, and then do the Open of page 2, but it didn't work. I would appreciate if anyone knows how to do this, thank you very much.
This is pretty old, you've probably figured it out or given up by now. In case you haven't:
If you want to Hide a layer, just Hide the layer. This did exactly what you're describing: (I've inserted your IDs)
data:action/json,{"actions":[{"hide":{"cells":["SvuciECQg7tZUCU10AH1-3"]}},{"open":"data:page/id,IZEQzf0yfGXm-2QJ5-Q8"}]}
If you need to toggle the layer back on, you'll need to Show it again. The code you have works, it's kindof unexpected not knowing if the layer is showing or hidden at the start.
Unless the layer you want to show/hide is on the different page.
You won't be able to interact with objects on a page that's not in scope. In that case, you probably want to hide the layer by default. That way, when you Open the second page, the layer is already hidden.

WXWidgets TextCtrl or RichTextCtrl

I'm using wxWidgets for a log window of a piece of software which runs for many hours. The log can accumulate 10,000's of entries. Does the community have a suggestion for how not to have the GUI thread choke for many seconds when updating a textctrl or richtextctrl with this many lines? I'm open to using either control type but richtext is preferable to I can highlight warnings or errors.
It's currently set to readonly, so undo, redo, paste, etc are not active. I'm currently freezing and thawing it before and after adding content.
In a test case, I add 10000 lines to the text control with a freeze and thaw before and after. This operation still takes over a minute. Are these text controls simply incapable of handling long content?
Assuming your display is like a log, where each "line" is it's own entry, try using the wxListCtrl in "virtual mode". Basically, you maintain the data in your own control (a vector, array, whatever works) and the control asks you for only the data that is currently visible.
Inherit wxListCtrl with your own class and implement OnGetItem. When a row is visible, your derived control will have this method called for each row (and each column if you implement multiple columns) and you provide it with the data for that row, accessed directly from your array (list, vector, whatever).
More information is available in the wxWidgets docs here: http://docs.wxwidgets.org/3.0/classwx_list_ctrl.html#a92370967f97215e6068326645ee76624
The suggestion to use wxListCtrl in #avariant answer is a good one, however a wxTextCtrl with wxTE_RICH style should still be capable of appending 10000 lines in well less than a minute if you freeze/thaw it before/after. I'd be curious to know if you can reproduce the problem in the text sample included with wxWidgets (which already has a menu item doing something like this) and, if so, which wxWidgets port do you use.

Is there any way with Calabash to Query ALL objects in a screen? (really all)

With Calabash, the Query("all *") gets about twice as much data as the query("*") alone does, but I still have data I cannot read without complex scroll logic.
Is there any good way to get a true 'All' data from a screen without scrolling?
For example, I have a screen with 12 containers each with 5-10 distinct pieces of data. I need to be able to read my containers to validate the data on the page.
query returns all visible views.
query("all *") disables the visibility heuristics and returns all views.
Even when using all, some part of the view rect must exist within the bounds of the screen.
without scrolling
If you are using Calabash iOS, you can try the scroll_to_* methods which are documented here:
http://calabashapi.xamarin.com/ios/Calabash/Cucumber/Core.html
scroll_to_mark is the most generic - I recommend starting with that method.

Create interactive cartesian grid in django

I have a question regarding a platform I'm developing called e-cidadania (GPL). One of the applications will be something like a blackboard where you can put messages. I've been requested to do it like a cartesian grid (p.e. x = good/bad, y = expensive/cheap). My question is, does anybody know about an application like that for django? Or in case that there isn't, how can I do it? I have no idea where to start.
I'll explain a use case, if someone didn't understand: You are in a classroom, the teacher draws on the blackboard the axis and tells the students to write a note. After that every student will put his note according to the axis.
I am not sure if I completely understand your question, but if I'm correct you want the user to input text (name of restaurant or something like that) and instead of showing 2 sliders or dropdown boxes for rating and price, you want to show a cartesian chart where the user can click somewhere, thus entering the 2 values with one click.
This has nothing to do with Django or Python, this is pure client side. Think javascript. One way is to show an image with the cartesian grid, set an onclick handler and see where in the image the click was made. Showing the selected point could be done simply by setting a colored div with an absolute position (relative on the position of the image).
I don't know any plug-and-play solutions, but building this shouldn't be too hard.
On a separate note: I doubt this will actually be more userfriendly for the user then simply using two sliders.
Update:
Or if you want to show a big cartesian chart where the user actually has to input the text on the correct position, this can be done with the same idea: create the text-input, but hide it (display:none). Then when the user clicks somewhere on the chart, move the text-input to the correct position and show it.
This may be a little far fetched, but instead of doing this with django alone, why dont u do this client side using javascript?
Hear me out here.
The highcharts graphing plugin has an option that allows u to add points on a (cartesian) graph. Check this example. The plugin also allows you to display custom messages when hovering on points, so you could use that to display the actual message, and you could handle the actual saving of the new message by submitting the newly added message via Ajax.

Refresh text shown in a GTK+ widget?

Being resonably new to using GTK+, im not fully aware of all its functionality.
Basically, I have a GtkTreeView widget that has 4 Columns. I need to update the text displayed in the 4 columns every couple of seconds, but im not aware how to do this in GTK+.
I'm aware that I could flush the data using gtk_tree_store_clear, but I'm not sure how to repopulate the columns and have the top level window refresh to show this new data?
You need to get a GtkTreeIter to the proper row, then use the appropriate (model-specific) setter to change the data.
For instance gtk_list_store_set() for the GtkListStore model.
There is no need to clear the entire model if you just want to change some of the data, that is very wasteful and slow.
If you really need to change all the data, then sure, clear it.
You don't have to worry about getting the display to refresh; the view listens to events from the model, and automatically knows to refresh when the model changes.
UPDATE:
When changing the data (as described in commment), you don't need to "flush" the old data. The model owns the data, and knows how to keep track of the memory used. You just use the above-mentioned gtk_list_store_set() call as necessary to put the new desired data in the model. You can do this as often as necessary, and an update frequency of once every few seconds should be no problem at all.
Of course, in such a case, to keep your application (which I assume is single-threaded, for simplicity) responsive, you must have a way to asynchronously trigger an update, perhaps using a timer. Have a look at glib's g_timeout_add() function to learn how to add a simple global timer.