Difference between revisions of "AnyWave:DeveloperCorner"

From WikiMEG
Jump to: navigation, search
(Step 3: Let's code)
(Step 3: Let's code)
Line 90: Line 90:
  
 
==Step 3: Let's code==
 
==Step 3: Let's code==
The header file<br/>
+
The header file:<br/>
 +
<syntaxhighlight lang="c++">
 +
#pragma once
 +
#include <AwFileIO.h>
 +
 
 +
class Q_DECL_EXPORT MyReader : public AwFileIO
 +
{
 +
  Q_OBJECT
 +
  Q_INTERFACES(AwFileIO)
 +
public:
 +
  explicit MyReader(const QString& fileName);
 +
  ~MyReader();
 +
 
 +
  qint64 readDataFromChannels(float start, float duration, QList<AwChannel *>& channels) override;
 +
  AwFileIO::FileStatus openFile(const QString &path) override;
 +
  AwFileIO::FileStatus canRead(const QString &path) override;
 +
  void cleanUpAndClose() override;
 +
};
 +
</syntaxhighlight>
  
 
=Build a signal processing plug-in=
 
=Build a signal processing plug-in=

Revision as of 14:20, 6 September 2018

Welcome

This part of the Wiki is dedicated to developers who would like to implement their own plug-ins for AnyWave.
AnyWave is written using the Qt Framework and the Qt plugin mechanism, so a good knowledge of the Qt Framework is required.

The SDK

If you have installed AnyWave on your system, you will find all the required files in the installation folder.

Linux

Build from sources following the instructions on our Gitlab.
Considering the default installation path, the requires folders to build a plugin are:

  • /usr/local/AnyWave/include
  • /usr/local/AnyWave/lib

Mac OS

The required folders to build a plugin are:

  • /Applications/AnyWave.app/Contents/include
  • /Applications/AnyWave.app/Contents/dylibs

Windows

The required folders to build a plugin are:

  • AnyWave\include
  • AnyWave\lib

Basic requirements to build a plugin

We strongly recommend QtCreator as the tool to use which is available along with the Qt open source package you will need to build a plugin.
Download Qt and Qt Creator here: Get Qt and Qt Creator
Note about Windows:
The Windows version of AnyWave is built with Visual Studio 2017 though, so, if you plan to build a plugin for Windows, consider using Visual Studio along with the Qt VS Addin.
Technically speaking you can build a plugin with QtCreator using another compiler like gcc or clang.
You will need to put the runtime DLL files of the chosen compiler into the AnyWave folder after you copied the plugin into the Plugins subdirectory.

Prepare a project

Every Qt project starts with a .pro file which is the format used by qmake, the tool for building Qt projects.
Building an AnyWave plugin requires that the paths to AnyWave headers and libraries must be set.
A good practice is to set an environment variable called AW_ROOT that points to the root folder of your AnyWave installation.
Example:

CONFIG += release warn_off c++11 plugin
ROOT=$$(AW_ROOT)
# on Mac OS the required folders are located inside the application bundle.
macx{
ROOT = $$(AW_ROOT)/Contents
}
INCLUDEPATH += $$ROOT/include
LIBS += -L$$ROOT/lib
DESTDIR = $$ROOT/Plugins
 
# Mac OS application has a separated folder for Plugins.
macx {
DESTDIR = $$ROOT/../../Anywave_Plugins
# shared libs on Mac are located in the application bundle.
LIBS += -F/Library/Frameworks -L$$ROOT/dylibs
}

You may use this file as .pri that you could include in every project you plan to develop:
Get plugins.pri file

Build a reader plugin

As a tutorial, we are going to develop here a reader plugin called "My Reader".
Each Qt project starts with a .pro file which qmake use to compile and link a Qt project.
A Reader plugin is a Qt shared library that should be placed in the Plugins directory of AnyWave.

Step 1: Prepare the folder

Let's create a folder in which we will put the files required to build our plugin:

mkdir MyReader && cd MyReader

Step 2: create the project file

Now we can create the .pro file for our project:

# We assume that the plugins.pri file is also in our plugin directory.
include(plugins.pri)
# The name of our plugin
TARGET=MyReader
# Our project must be a library
TEMPLATE = lib
# Just to avoid unwanted libs, Qt GUI is not usefull for a reader plugin (no widgets/no graphics items).
QT -= gui
 
# We must link with some AnyWave libs
#  AwRW is the AnyWave ReadWrite lib.
unix{
LIBS += -lAwRW  
}
win32{
LIBS += AwReadWriteLib.lib
}
 
HEADERS += MyReader.h
SOURCES += MyReader.cpp

Step 3: Let's code

The header file:

Invalid language.

You need to specify a language like this: <source lang="html4strict">...</source>

Supported languages for syntax highlighting:

4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, arm, asm, asp, asymptote, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcl, dcpu16, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, freeswitch, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, haxe, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, ldif, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, nagios, netrexx, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, octave, oobas, oorexx, oracle11, oracle8, oxygene, oz, parasail, parigp, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, pys60, python, q, qbasic, rails, rebol, reg, rexx, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, spark, sparql, sql, stonescript, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, upc, urbi, uscript, vala, vb, vbnet, vedit, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic


#pragma once
#include <AwFileIO.h>

class Q_DECL_EXPORT MyReader : public AwFileIO
{
   Q_OBJECT
   Q_INTERFACES(AwFileIO)
public:
   explicit MyReader(const QString& fileName);
   ~MyReader();

  qint64 readDataFromChannels(float start, float duration, QList<AwChannel *>& channels) override;
  AwFileIO::FileStatus openFile(const QString &path) override;
  AwFileIO::FileStatus canRead(const QString &path) override;
  void cleanUpAndClose() override;
};

Build a signal processing plug-in

How to write a MATLAB plug-in

MATLAB API

How to write a Python Scripted plug-in