Ada: plotting 2d graphs - graph

it would be interesting to be able to plot a 2D graph within an Ada code rather than having to save values say to file and use an external drawing software afterwards. A search on the web has taken me to two packages: Win_IO and JEWL. I have been able to use WIN_IO though but the documentation is quite poor and having just started using it, it seems that it is not possible to resize the size of the canvas. I use the GPS editor and I get complaint when running Win_IO that some fonts are not available on my system and that the output will be ugly. Finally the plot doesn't itself pop up on the screen; One has to click on the exe file of the file being compiled and linked so as to get the graph.
I have taken a look also at JEWL but it doesn't seem to be able to plot graphs.
Are there more Ada packages available out there for plotting 2D graphs.
Thanks a lot...
My experience with GNAVI:
The installation instructions are at
http://www.gnavi.org/index.php?Command=Class&ClassID=Start&CID=381
Basically the installation consists of:
To use:
Place this directory on your path
cd to gnatcom and run: make install
cd to gwindows and run: make UNICODE=1 all
run: gnavi_ide and enjoy :-)
But the installation is plagued with errors:
C:\gnavi\gnatcom>install
Installing GNATCOM.....
MAKE Version 5.2 Copyright (c) 1987, 2000 Borland
Error makefile 2: Command syntax error
* 1 errors during make *
Install Completed
C:\gnavi\gwindows>make UNICODE=1 all
MAKE Version 5.2 Copyright (c) 1987, 2000 Borland
Error makefile 2: Command syntax error
* 1 errors during make *
And though C:GNAVI is on my path, the IDE still complains that icg.exe which is found in C:GNAVI is not on the path.`This is trouble with software which has not been fully tested!!! I was very disappointed that people can write irresponsible and incomplete installation instructions. Have the developers even found out that whether a normal user can install their software?
I have also try to look at AdaDesigner at https://gna.org/projects/adadesigner
Here, FireFox complains: This Connection is Untrusted
gna.org uses an invalid security certificate.
The certificate is not trusted because the issuer certificate is unknown.
I decided not to visit such a website.

PLplot is a cross-platform package for creating scientific plots. It has a well-documented Ada binding. For reference, this gallery illustrates a variety of plots. Click a thumbnail to view a full-size image. Click either Ada tab (standard or traditional) to see the corresponding source code.

I'd give a try to GTKAda. I'm not completely sure this subsystem would allow you to do 2D graphs as I've never used it for that purpose, but it can be done with GTK+ (C/C++).
There is also a guide on GTKAda and a reference manual, some documentation on the GTK toolkit itself may also come handy.

It depends on exactly what you want to do. For graphing node-based diagrams, the first thing I'd look into using is Graphviz. It has its own special graphing language it uses, but I'm all about using Domain Specific Languages when appropriate. Ada has great interoperability, so using DSLs with it can really make it powerful.
An example I found is AdaDesigner, which generates Graphviz DOT files to help visualze the structure of Ada code.
The one time in the past I had to do simple plotting, it was for a web app. I ended up dynamically generating SVG pages on the server side (even though it was poorly supported then). Support is better now, so I'd definitely use it again today.
If working directly on a Windows PC display appeals more to you, there are several options for GUI bindings, all of which should support drawing lines and points on a canvas. In addtion to GTK (which is both powerful and portable), there are a few Win32 API's floating around. I think one comes with Gnat. Another you might not be aware of is GWindows. It is part of GNAVI, which aims to be sort of an OpenSource alternative to Delphi. It isn't the most active of projects, but is (reportedly) quite useable, and is still being worked on and used. Here are some screenshots of it being used for plotting.
(source: gnavi.org)

MathGL is cross-platform GPL plotting library. It have C interface, so you can use it from yours code too. Also it can create a window with graphics -- i.e. you don't need to study/use other widget libraries in simplest case.

Related

Julia's equivalents to R's help pages and vignettes?

Coming from an R background, and just started learning Julia, I wonder how's documentation in Julia, and if there are analogues to R's help pages and vignettes.
Furthermore, in R, one can document functions using roxygen comment blocks, is there also something similar in Julia?
I think it is best to understand how things work by example. I will comment on how DataFrames.jl is documented as this is a pretty standard approach:
Functions are documented using docstrings, here is an example of a docstring of function names; These docstrings are then discoverable interactively via help system (by pressing ?)
A standard way to generate a documentation for a package is to use Documenter.jl; by the way: the package has a great team of maintainers who are very helpful and responsive; here you have a link to the make.jl file that is executed to generate the documentation; note in particular the option doctest=true which makes sure that all code examples that are properly anoteted following Documenter.jl rules are producing an expected output
In order to set-up auto-generation of package documentation you need to set up CI integration on GitHub; again - there are many ways to do it; a standard one is to use GitHub Actions; here you have a link to the part of the ci.yml specification file that ensures that documentation is built as a part of CI; then in any PR, e.g. this one (I am giving a link to a currently open PR that is documentation related) you can see in the section reporting CI results that after running tests also documentation was generated. Here you can see how a documentation generated using this toolchain looks like (e.g. note that at the bottom you can switch the version of the package you want to read manual of dynamically which shows you that all here is really well integrated - not just a bunch of PDF or HTML files).
I hope this will help you to get started. I have pointed you to all essential pieces that are normally used by packages hosted on GitHub (i.e. this is not the only way to do it, but it is a standard way most commonly used).
To master all the details of the above you need to read the documentation in the Julia Manual and Documenter.jl carefully. Unfortunately writing a proper documentation is not easy (in any programming language). The good thing is that Julia has a really excellent toolchain that supports this process very well.

AutoCAD drawing (DWG) to map tiles

Rendering large DWG files as such has shown performance degradation to large extent. Planning to use the concept of map tiles using leaflet. Need some pointers/information on how to convert DWG files to map tiles.
After too many hours, searching everywhere for a solution to convert DWG/DXF files using any automated command line tool, finally I found QCAD.org.
And that works even on Windows, MacOS and Linux.
After a quick look in documentation, I found the section for command line tools.
They are:
dwg2bmp, dwg2png, dwg2jpeg, dwg2tiff, dxf2png, dxf2jpeg, dxf2tiff
and the awesome:
dwg2maptiles and dxf2maptiles
Using this tool, they came up with a beautiful sample using leaflet.js:
http://qcad.org/res/map/
The project is OpenSource, but this scripts are only avaliable at QCAD Professional edition.
You can use the free open source QCAD Community Edition by downloading the trial version for your platform (Win, Mac, Linux) and then remove the QCAD Professional add-on running in trial mode. Alternatively, you may compile your own package from sources.
PS: I'm very happy to support the project buying a professional copy.
The easiest approach may be to save your DWG files as PDF and use MapTiler to create the raster tiles and leaflet viewer for you.
You can render such PDF by drag&drop into MapTiler while choosing the "raster" profile - just follow the video tutorial: https://youtu.be/9iYKmRsGoxg?list=PLGHe6Moaz52PiQd1mO-S9QrCjqSn1v-ay
If you need to assign coordinates for later on placing markers or polygons on specified position over the DWG tiles - it is possible with advanced tiles.
If you need help with using MapTiler - write details and provide sample file you need to process to https://www.maptiler.com/support/community/.
If you data are sensitive or you need a guarantee on the answering of your request you seek directly the support from us, the authors of MapTiler.

Ada dependency graph

I need to create a dependency graph for a software suite that I am working on. In the past the company I work for has always done this manually, but I am guessing that there is a tool somewhere that will do what we need.
The software I am working with is Ada95, and has about 200 code modules/files, with about 40 packages. I need to create a map that will trace every output, individually, back to each input or constant that will have an impact on the output. Does anybody know of a tool that would accomplish this? Or even just partially accomplish it?
AdaCore's GPS (available from http://libre.adacore.com) comes with a command line tool named gnatinspect. You can use this tool to load all cross-reference information generated by the compiler (assuming you are compiling with GNAT). This creates a sqlite database (gnatinspect.db) which contains all information you need. gnatinspect itself provides a number of pre-made queries that might get you at least partially to where you want to go.
You could also look at ASIS, as a way to do this kind of queries directly on the code. I am told this is not so easy to use the first time around though.
There is also an older tool provided with gnat (gnatxref) which does something similar, although it is being superceded by gnatinspect.
Finally, you could look at gnat2xml as an alternative to ASIS if you are more comfortable parsing XML files.

R statistics console in QT

I am planning to link a Qt project against R to provide some statistical funcionality. I thought it might be quite cute to add some generality to the project by having an R console as a Qt widget within the tab to allow me to do analyses that I haven't thought of in the design stage later on. I was wondering whether it is something that might be accomplished fairly easily?
In particular I'm stuck on how I would access the RTerm from QT? Has anyone else attempted something similar or can give some hints on where to start?
One of the examples for RInside does something pretty close---in around 200 lines most of which deal with the other GUI aspects, it wraps R functionality inside a Qt application.
The example implements a GUI density slider, and the edit box allows you to write an almost arbitrary R expression, or rather the parts that are then passed into an evaluation to generate random number: rnorm(50), or for a mixture c(rnorm(50), rt(50)) etc. You could possibly build on top of that.
See this blog post for more.
Check out Carson Farmer's work on manageR:
http://www.ftools.ca/manageR/
this is a plugin for Quantum GIS (mapping package) that interfaces it to R, giving you exactly what you want - an R console wrapped in a Qt4 body - as well as data transfer between Qgis and R. It handles plots as well.
I've tried to encourage Carson to produce a standalone R Gui project from this code, but he's a busy guy. Aren't we all?
RStudio is largely written using QT, you should be able to have a look at their code and build something similar into your Qt based application:
https://github.com/rstudio/rstudio

How to auto-post math markup on my github repo's page(s)?

I'm not sure if this is possible, but this is what I'd like to do:
I'd like to create a literate program, hosted on github, and have the resulting human-friendly literature automatically published on my github's project page. By "automatically published," I mean that I can run a script on my local machine that ends with "git push origin master," and ends up with a published human-friendly, math-containing document on github. I'm open to compromises on the procedure to get there, but the simpler, the better.
Many people don't know what literate programming is, so I'll summarize that. It's a system where you write a single document that can be translated into either source code or a human-friendly document. The purpose is to very clearly explain the algorithm, in English (or other natural language), and it is considered useful when users may be as interested in reading about your algorithm as they are in using it directly. Some folks (like Donald Knuth) consider literate programming as a critical tool in building any complex piece of software.
One idea to do this would be to generate something like a README.md file as the output of the literate program, but I don't know of any math support in github's markdown formatting. It looks like github's wikis might support some math, but I don't know how to make the wiki be generated from the code -- as in, I'd like to be able to do a git push origin master from my machine, and have the github wiki automatically updated.
(Also, to understand why math support is important: I'm coming from a world of always using TeX or LaTeX to write papers, and I'm interested in a general system that other authors used to LaTeX could also use.)
Any ideas how to achieve this?
The wikis are backed by their own git repo, so you can push to it and have it automatically update. That's a different repo than the main one though. As far as I know that stuff is only supported in the wikis, not in the main repo markdown processor.

Resources