wxGetElapsedTime function in wxWidgets 2.9+ - c++

I'm trying to follow some old C++ tutorial which use old version o wxWidgets framework (2.6 I think), but I have complied version 2.9.1, where I could not find wxGetElapsedTime() and wxStartTimer() methods.
The elapsed time method is used as argument to srand() method to 'randomize' initial random seed value and the author of the tutorial use after that wxStartTimer() to reset timer to zero (instead of use wxGetElapsedTime(true)).
srand(wxGetElapsedTime(false));
wxStartTimer();
After some search on Google I found, that those methods are deprecated, but I could not find some clue which functions are used in 2.9+ wxWidgets instead.

try
srand((int)wxGetLocalTime());
and
wxStopWatch * stopWatch = new wxStopWatch();
updateSomethingByTime( stopWatch->Time() );

You could try the wxStopWatch class it has methods like those for measuring times. Not sure how you'd get the system uptime for seeding srand() though, although you could get the current time from wxDateTime and use that.

Related

Alternative of CreateVideoSource() in webrtc

Hi all I had seen one webrtc old source code which has this method called CreateVideoSource() for adding streams after an CreateAudioTrack() call.
rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> video_source =
peer_connection_factory_->CreateVideoSource(std::unique_ptr<cricket::VideoCapturer>(
media_source->GetVideoCapturer()),
NULL);
What's happening is whenever I try to build it gives an error for the above CreateVideoSource() that it is undefined. And the reason behind that is the latest webrtc-checkout has deprecated this.
So my question is, I wanted to know the alternative which they have introduced after deprecating this method. So can anyone tell me what the alternate approach is.
Okay, Finally I was able to come up with an alternative(i.e the current implementation of libwebrtc) after looking into bundle examples and tests.
Line 71 is a good point to start

Veins : TraCIMobility::getSignals() method information

Good afternoon.
I'm using Veins v4.4 and Sumo 0.25 with Omnet++ v4.6.
I was trying to get information about brakes and blinkers: I've found the VehicleSignal field in TraCISCenarioManager.h and the getSignals() method in TraCIMobility.h , but as soon as I call this function in my code, it runs in exception since I suppose the variable is never updated. Shouldn't it be updated runtime from Sumo?
Thanks for helping
You found some functionality that was never fully implemented in Veins 4.4. As a quick hack, you can make this work by changing line 891 of TraCIScenarioManager.cc to also update each vehicle's signal field, e.g., as follows:
mm->nextPosition(p, edge, speed, angle, VehicleSignal(signals));

Call Lua function from C++ using LuaBridge

I am having some trouble calling Lua functions from C++ using LuaBridge. The idea is that I want to call "Update" on the script on every game update in C++. The following code is what I have found online:
LuaRef sumNumbers = getGlobal(L, "sumNumbers");
int result = sumNumbers(5, 4);
So in my case this would be:
LuaRef updateFunction = getGlobal(L, "Update");
updateFunction();
However, the getGlobal does not seem to exist in LuaBridge 2.0 (luabridge namespace). This is different from the lua_getglobal
I am wondering if this has been replaced by a different function call or if it has been deprecated out of the 2.0 version. I can of course use the normal C Lua approach, but I was wondering if this has been abstracted in LuaBridge (to make things easier)
Make sure you're using the latest source from the github project repository. When I tested this from luabridge's master branch, luabridge::getGlobal is present and working.

Gtk::ScaleButton: Icons in the constructor

I am trying to use a Gtk::ScaleButton in Gtkmm 3. My problem is the constructor. It needs as last parameter (see here: https://developer.gnome.org/gtkmm/stable/classGtk_1_1ScaleButton.html#a96753b6cb6b8adb0ed3727ba3eb8cfb7 ) a vector of ustrings. I guess (i can't find it in the docs what it means exactly) i have to give it the path to the +/- Images. I want to use the Gtk Stock items for +/-. How can i achieve this?
Currently i give it an empty vector, which results in a glibmm warning:
std::vector<Glib::ustring> icons;
Gtk::ScaleButton * scale = Gtk::manage(new Gtk::ScaleButton(Gtk::ICON_SIZE_SMALL_TOOLBAR, 0.0, 10.0, 1.0, icons));
Warning:
glibmm-WARNING **: Glib::ConstructParams::ConstructParams(): object class "gtkmm__GtkScaleButton" has no property named "min"
How can i avoid the warning and give it stock icons?
You must be one of the first people to ever try using this Gtk::ScaleButton constructor from gtkmm. It seems to have been broken for several years.
I've fixed it in gtkmm: https://git.gnome.org/browse/gtkmm/commit/?id=26f94d231da9481d74acdd94e56168ed6b38609a
But it will be some time until that is widely available via Linux distro packages. In the meantime you can try using
Gtk::ScaleButton* button = Glib::wrap(gtk_scale_button_new(whatever));
See https://developer.gnome.org/gtkmm-tutorial/stable/sec-basics-gobj-and-wrap.html.en
However, I don't know how it's actually meant to behave, so you might encounter other bugs. You might actually want to use the derived Gtk::VolumeButton instead.
andlabs is correct that the GTK+ documentation describes the icons better:
https://developer.gnome.org/gtk3/stable/GtkScaleButton.html#GtkScaleButton--icons
and those should indeed probably be the standard icon names:
http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html

Setting the version number in an NCBI c++ toolkit app

How can I set the version number in a NCBI C++ Toolkit Application?
I mean the version number which is displayed when I start my program with the parameter -version.
I read through the docs, but have not found it yet.
(I know this is a highly specific question, but I figured it was worth a try)
Give it a void Init(void) method containing code along the following lines:
// the last two parameters are optional
CVersionInfo version_info(1, 2, 3, "My App");
SetVersion(version_info);
However, this is currently broken (bug already submitted), so the workaround is to give the application class a constructor and call SetVersion from there.