Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) VisualAbc

 

Visual ABC is an application to work with ABC notation files: it allows to view the generated sheet music by a single click and to

 

 

 

 

 

 

Downloads

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./ToolVisualAbc/ToolVisualAbcDesktop.pro

 

include(../../DesktopApplication.pri)

include(../../Libraries/Boost.pri)
include(../../Libraries/GeneralConsole.pri)
include(../../Libraries/GeneralDesktop.pri)

#Specific
include(../../Classes/CppMusic/CppMusic.pri)
include(ToolVisualAbcDesktop.pri)

SOURCES += qtmain.cpp

 

 

 

 

 

./ToolVisualAbc/ToolVisualAbcConsole.pri

 

INCLUDEPATH += \
    ../../Tools/ToolVisualAbc

SOURCES += \
    ../../Tools/ToolVisualAbc/visualabccheckprerequisites.cpp \
    ../../Tools/ToolVisualAbc/visualabcmenudialog.cpp \
    ../../Tools/ToolVisualAbc/visualabcmaindialog.cpp \
    ../../Tools/ToolVisualAbc/visualabcchords.cpp

HEADERS += \
    ../../Tools/ToolVisualAbc/visualabccheckprerequisites.h \
    ../../Tools/ToolVisualAbc/visualabcchords.h \
    ../../Tools/ToolVisualAbc/visualabcmaindialog.h \
    ../../Tools/ToolVisualAbc/visualabcmenudialog.h

OTHER_FILES += \
    ../../Tools/ToolVisualAbc/Licence.txt

RESOURCES += \
    ../../Tools/ToolVisualAbc/ToolVisualAbc.qrc

 

 

 

 

 

./ToolVisualAbc/ToolVisualAbcDesktop.pri

 

include(../../Tools/ToolVisualAbc/ToolVisualAbcConsole.pri)

FORMS += \
    ../../Tools/ToolVisualAbc/qtvisualabcchordsdialog.ui \
    ../../Tools/ToolVisualAbc/qtvisualabcmaindialog.ui \
    ../../Tools/ToolVisualAbc/qtvisualabcmenudialog.ui


SOURCES += \
    ../../Tools/ToolVisualAbc/qtvisualabcchordsdialog.cpp \
    ../../Tools/ToolVisualAbc/qtvisualabcmaindialog.cpp \
    ../../Tools/ToolVisualAbc/qtvisualabcmenudialog.cpp

HEADERS += \
    ../../Tools/ToolVisualAbc/qtvisualabcchordsdialog.h \
    ../../Tools/ToolVisualAbc/qtvisualabcmaindialog.h \
    ../../Tools/ToolVisualAbc/qtvisualabcmenudialog.h

 

 

 

 

 

./ToolVisualAbc/ToolVisualAbcWebsite.pri

 

include(../../Tools/ToolVisualAbc/ToolVisualAbcConsole.pri)

SOURCES +=

HEADERS +=

 

 

 

 

 

./ToolVisualAbc/qtmain.cpp

 

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include <QApplication>
#include "qtvisualabcmenudialog.h"
#include "visualabccheckprerequisites.h"
#pragma GCC diagnostic pop

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  ribi::CheckPrerequisites();
  ribi::QtVisualAbcMenuDialog w;
  w.show();
  return a.exec();
}

 

 

 

 

 

./ToolVisualAbc/qtvisualabcchordsdialog.h

 

#ifndef QTTOOLVISUALABCCHORDSDIALOG_H
#define QTTOOLVISUALABCCHORDSDIALOG_H

#include "qthideandshowdialog.h"

namespace Ui {
  class QtVisualAbcChordsDialog;
}

namespace ribi {

class QtVisualAbcChordsDialog : public QtHideAndShowDialog
{
    Q_OBJECT

public:
    explicit QtVisualAbcChordsDialog(QWidget *parent = 0);
    QtVisualAbcChordsDialog(const QtVisualAbcChordsDialog&) = delete;
    QtVisualAbcChordsDialog& operator=(const QtVisualAbcChordsDialog&) = delete;
    ~QtVisualAbcChordsDialog() noexcept;

private:
    Ui::QtVisualAbcChordsDialog *ui;
};

} //~namespace ribi

#endif // QTTOOLVISUALABCCHORDSDIALOG_H

 

 

 

 

 

./ToolVisualAbc/qtvisualabcchordsdialog.cpp

 

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#include "qtvisualabcchordsdialog.h"
#include "ui_qtvisualabcchordsdialog.h"
#pragma GCC diagnostic pop

ribi::QtVisualAbcChordsDialog::QtVisualAbcChordsDialog(QWidget *parent)
  : QtHideAndShowDialog(parent),
    ui(new Ui::QtVisualAbcChordsDialog)
{
    ui->setupUi(this);
}

ribi::QtVisualAbcChordsDialog::~QtVisualAbcChordsDialog() noexcept
{
    delete ui;
}

 

 

 

 

 

./ToolVisualAbc/qtvisualabcmaindialog.h

 

#ifndef QTTOOLVISUALABCMAINDIALOG_H
#define QTTOOLVISUALABCMAINDIALOG_H

#include "qthideandshowdialog.h"

namespace Ui {
  class QtVisualAbcMainDialog;
}

namespace ribi {

class QtVisualAbcMainDialog : public QtHideAndShowDialog
{
  Q_OBJECT

public:
  explicit QtVisualAbcMainDialog(QWidget *parent = 0);
  QtVisualAbcMainDialog(const QtVisualAbcMainDialog&) = delete;
  QtVisualAbcMainDialog& operator=(const QtVisualAbcMainDialog&) = delete;
  ~QtVisualAbcMainDialog() noexcept;

private:
  Ui::QtVisualAbcMainDialog *ui;
  void resizeEvent(QResizeEvent *);

private slots:
  void on_label_save_clicked();
  void on_button_play_clicked();
  void on_button_convert_clicked();

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif
};

} //~namespace ribi

#endif // QTTOOLVISUALABCMAINDIALOG_H

 

 

 

 

 

./ToolVisualAbc/qtvisualabcmaindialog.cpp

 

#include <fstream>
#include <iostream>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#include <boost/lexical_cast.hpp>

#include <QDesktopWidget>
#include <QFile>
#include <QFileDialog>

#include "fileio.h"
#include "qtvisualabcmaindialog.h"
#include "testtimer.h"
#include "trace.h"
#include "ui_qtvisualabcmaindialog.h"
#include "visualabcmaindialog.h"
#pragma GCC diagnostic pop

ribi::QtVisualAbcMainDialog::QtVisualAbcMainDialog(QWidget *parent)
  : QtHideAndShowDialog(parent),
    ui(new Ui::QtVisualAbcMainDialog)
{
  #ifndef NDEBUG
  Test();
  #endif
  ui->setupUi(this);
  this->setMaximumWidth(1024);
  this->setMaximumHeight(768);

  //Set the example text
  {
    const std::vector<std::string> v = VisualAbcMainDialog::GetAbcFriday();
    std::string t;
    for(const std::string& s: v)
    {
      t+=s;
      t+='\n';
    }
    //Pop trailing '\n'
    t.resize(t.size() - 1);
    ui->edit_text->setPlainText(t.c_str());
  }

  this->on_button_convert_clicked();
}

ribi::QtVisualAbcMainDialog::~QtVisualAbcMainDialog() noexcept
{
  {
    std::ofstream f("last_text.abc");
    f << ui->edit_text->toPlainText().toStdString();
  }

  delete ui;
}

void ribi::QtVisualAbcMainDialog::on_button_convert_clicked()
{
  VisualAbcMainDialog::ConvertToPng(ui->edit_text->toPlainText().toStdString());
  if (ribi::fileio::FileIo().IsRegularFile(VisualAbcMainDialog::m_png_filename))
  {
    ui->label_sheet->setPixmap(QPixmap(VisualAbcMainDialog::m_png_filename.c_str()));
  }
  else
  {
    assert(ribi::fileio::FileIo().IsRegularFile(VisualAbcMainDialog::m_pngs_filename));
    ui->label_sheet->setPixmap(QPixmap(VisualAbcMainDialog::m_pngs_filename.c_str()));
  }
}

void ribi::QtVisualAbcMainDialog::on_button_play_clicked()
{
  VisualAbcMainDialog::ConvertToMid(ui->edit_text->toPlainText().toStdString());
  VisualAbcMainDialog::PlayMid();
}

void ribi::QtVisualAbcMainDialog::resizeEvent(QResizeEvent *)
{

  this->setMaximumWidth(1024);
  //this->setMaximumHeight(768);

  ui->label_sheet->setMaximumWidth(1024 - 32);
  //ui->label_sheet->setMaximumHeight(300);

  //Put the dialog in the screen center
  const QRect screen = QApplication::desktop()->screenGeometry();
  this->move( screen.center() - this->rect().center() );
}

void ribi::QtVisualAbcMainDialog::on_label_save_clicked()
{
  const std::string filename
    = QFileDialog::getOpenFileName(this,
     "Save your ABC file","", "ABC notation file (*.abc)").toStdString();
  std::ofstream file(filename.c_str());
  file << ui->edit_text->toPlainText().toStdString();
}


#ifndef NDEBUG
void ribi::QtVisualAbcMainDialog::Test() noexcept
{
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  const TestTimer test_timer(__func__,__FILE__,1.0);
}
#endif

 

 

 

 

 

./ToolVisualAbc/qtvisualabcmenudialog.h

 

#ifndef QTTOOLVISUALABCMENUDIALOG_H
#define QTTOOLVISUALABCMENUDIALOG_H

#include "qthideandshowdialog.h"

namespace Ui {
  class QtVisualAbcMenuDialog;
}

namespace ribi {

class QtVisualAbcMenuDialog : public QtHideAndShowDialog
{
  Q_OBJECT

public:
  explicit QtVisualAbcMenuDialog(QWidget *parent = 0);
  QtVisualAbcMenuDialog(const QtVisualAbcMenuDialog&) = delete;
  QtVisualAbcMenuDialog& operator=(const QtVisualAbcMenuDialog&) = delete;
  ~QtVisualAbcMenuDialog() noexcept;

private:
  Ui::QtVisualAbcMenuDialog *ui;

private slots:
  void on_button_quit_clicked();
  void on_button_about_clicked();
  void on_button_start_clicked();

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif
};

} //~namespace ribi

#endif // QTTOOLVISUALABCMENUDIALOG_H

 

 

 

 

 

./ToolVisualAbc/qtvisualabcmenudialog.cpp

 

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#include "about.h"
#include "qtaboutdialog.h"
#include "qtvisualabcmaindialog.h"
#include "qtvisualabcmenudialog.h"
#include "trace.h"
#include "ui_qtvisualabcmenudialog.h"
#include "testtimer.h"
#include "visualabcmenudialog.h"
#pragma GCC diagnostic pop

ribi::QtVisualAbcMenuDialog::QtVisualAbcMenuDialog(QWidget *parent)
  : QtHideAndShowDialog(parent),
    ui(new Ui::QtVisualAbcMenuDialog)
{
  #ifndef NDEBUG
  Test();
  #endif
  ui->setupUi(this);
}

ribi::QtVisualAbcMenuDialog::~QtVisualAbcMenuDialog() noexcept
{
  delete ui;
}

void ribi::QtVisualAbcMenuDialog::on_button_start_clicked()
{
  QtVisualAbcMainDialog d;
  this->ShowChild(&d);
}

void ribi::QtVisualAbcMenuDialog::on_button_about_clicked()
{
  About a = VisualAbcMenuDialog().GetAbout();
  QtAboutDialog d(a);
  this->ShowChild(&d);
}

void ribi::QtVisualAbcMenuDialog::on_button_quit_clicked()
{
  close();
}

#ifndef NDEBUG
void ribi::QtVisualAbcMenuDialog::Test() noexcept
{
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  const TestTimer test_timer(__func__,__FILE__,1.0);
}
#endif

 

 

 

 

 

./ToolVisualAbc/visualabccheckprerequisites.h

 

#ifndef TOOLVISUALABCCHECKPREREQUISITES_H
#define TOOLVISUALABCCHECKPREREQUISITES_H

namespace ribi {

struct CheckPrerequisites
{
  CheckPrerequisites();

  private:
  void CheckAbc2midi();
  void CheckAbcm2ps();
  void CheckConvert();
  void CheckPlaysound();
};

} //~namespace ribi

#endif // TOOLVISUALABCCHECKPREREQUISITES_H

 

 

 

 

 

./ToolVisualAbc/visualabccheckprerequisites.cpp

 


#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <stdexcept>
#include <fstream>

#include "fileio.h"
#include "visualabccheckprerequisites.h"

ribi::CheckPrerequisites::CheckPrerequisites()
{
  CheckAbc2midi();
  CheckAbcm2ps();
  CheckConvert();
  CheckPlaysound();
}

void ribi::CheckPrerequisites::CheckAbc2midi()
{
  const std::string s { fileio::FileIo().GetTempFileName() };
  assert(!fileio::FileIo().IsRegularFile(s));
  const std::string cmd {
    "abc2midi > " + s
  };
  const int result
    = std::system(cmd.c_str());
  if (result != 0)
  {
    throw std::runtime_error(
      "\'abc2midi\' not not present. "
      "Type \'sudo apt-get install abcmidi\' to install");
  }
  fileio::FileIo().DeleteFile(s);
  assert(!fileio::FileIo().IsRegularFile(s));
}

void ribi::CheckPrerequisites::CheckAbcm2ps()
{
  const std::string s { fileio::FileIo().GetTempFileName() };
  assert(!fileio::FileIo().IsRegularFile(s));
  const std::string cmd {
    "abcm2ps > " + s
  };
  const int result
    = std::system(cmd.c_str());
  if (result != 0)
  {
    throw std::runtime_error(
      "\'abcm2ps\' not not present. "
      "Type \'sudo apt-get install abcm2ps\' to install");
  }

  fileio::FileIo().DeleteFile(s);
  assert(!fileio::FileIo().IsRegularFile(s));
}

void ribi::CheckPrerequisites::CheckConvert()
{
  const std::string s { fileio::FileIo().GetTempFileName() };
  assert(!fileio::FileIo().IsRegularFile(s));
  const std::string cmd {
    "convert --help > " + s
  };
  const int result
    = std::system(cmd.c_str());
  if (result != 0)
  {
    //FileExists("tmp.txt"))
    throw std::runtime_error(
      "\'convert\' not not present. "
      "Type \'sudo apt-get install imagemagick\' to install");
  }
  fileio::FileIo().DeleteFile(s);
  assert(!fileio::FileIo().IsRegularFile(s));
}

void ribi::CheckPrerequisites::CheckPlaysound()
{
  const std::string s { fileio::FileIo().GetTempFileName() };
  assert(!fileio::FileIo().IsRegularFile(s));
  const std::string cmd {
    "playsound --version > " + s
  };
  const int error
    = std::system(cmd.c_str());
  if (error || !fileio::FileIo().IsRegularFile(s))
  {
    assert(error);
    throw std::runtime_error(
      "\'playsound\' not not present. "
      "Type \'sudo apt-get install libsdl-sound1.2\' to install");
  }
  fileio::FileIo().DeleteFile(s);

  assert(!fileio::FileIo().IsRegularFile(s));
}

 

 

 

 

 

./ToolVisualAbc/visualabcchords.h

 

#ifndef TOOLVISUALABCCHORDS_H
#define TOOLVISUALABCCHORDS_H

#include <string>
#include <vector>

namespace ribi {

struct Chords
{
  static std::vector<std::string> GetChords();
};

} //~namespace ribi

#endif // TOOLVISUALABCCHORDS_H

 

 

 

 

 

./ToolVisualAbc/visualabcchords.cpp

 

#include "visualabcchords.h"

std::vector<std::string> ribi::Chords::GetChords()
{
  std::vector<std::string> v;
  v.push_back("Am: A  C  E: [ACE]");
  v.push_back("C : G  C  E: [GCE]");
  v.push_back("Dm: A  D  F: [ADF]");
  v.push_back("E : G# B  E: [G#BE]");
  v.push_back("F : A  C  F: [ACF]");
  v.push_back("G : G  B  D: [GBD]");
  return v;
}

 

 

 

 

 

./ToolVisualAbc/visualabcmaindialog.h

 

//---------------------------------------------------------------------------
/*
Visual ABC, visual ABC editor
Copyright (C) 2011-2015 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolVisualAbc.htm
//---------------------------------------------------------------------------
#ifndef TOOLVISUALABCMAINDIALOG_H
#define TOOLVISUALABCMAINDIALOG_H

#include <string>
#include <vector>

namespace ribi {

struct VisualAbcMainDialog
{
  static void ConvertToPng(const std::string& s);
  static void ConvertToMid(const std::string& s);
  static void PlayMid();
  static std::vector<std::string> GetAbcFriday();
  static std::string m_abc_filename;
  static std::string m_log_filename;
  static std::string m_mid_filename;
  static std::string m_png_filename;
  static std::string m_pngs_filename;
};

} //~namespace ribi

#endif // TOOLVISUALABCMAINDIALOG_H

 

 

 

 

 

./ToolVisualAbc/visualabcmaindialog.cpp

 

//---------------------------------------------------------------------------
/*
Visual ABC, visual ABC editor
Copyright (C) 2011-2015 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolVisualAbc.htm
//---------------------------------------------------------------------------
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <stdexcept>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include "visualabcmaindialog.h"
#pragma GCC diagnostic pop

std::string ribi::VisualAbcMainDialog::m_abc_filename = "temp.abc";
std::string ribi::VisualAbcMainDialog::m_log_filename = "temp.log";
std::string ribi::VisualAbcMainDialog::m_mid_filename = "temp.mid";
std::string ribi::VisualAbcMainDialog::m_png_filename = "temp.png";
std::string ribi::VisualAbcMainDialog::m_pngs_filename = "temp-0.png";

std::vector<std::string> ribi::VisualAbcMainDialog::GetAbcFriday()
{
  std::vector<std::string> v;
  v.push_back("X:1");
  v.push_back("T:Friday");
  v.push_back("C:Richel Bilderbeek");
  v.push_back("L:1/4");
  v.push_back("Q:1/4=240");
  v.push_back("M:4/4");
  v.push_back("K:B");
  v.push_back("V:V1 clef=treble");
  v.push_back("V:V2 clef=bass");
  v.push_back("%");
  v.push_back("% B  : F# B D#");
  v.push_back("% G#m: G# B D#");
  v.push_back("% E  : G# B E ");
  v.push_back("% F# : F# A# C#");
  v.push_back("% B Scale = C# D# E F# G# A# B ");
  v.push_back("% Intro 1-8");
  v.push_back("%");
  v.push_back("% Verse 1, 9-12");
  v.push_back("%");
  v.push_back("[V:V1] [FBd]2 d  B   | [FBd]2 d B   | [GBd]2 B d   | [GBd]2 B d    | ");
  v.push_back("w:     dot    se-ven | zip    ~ ex- | tract in the | mor-     ning |");
  v.push_back("[V:V2] B,,4          | B,4          | G,,4         | G,4           |");
  v.push_back("%      B             |              | G#m          |               | ");
  v.push_back("%");
  v.push_back("% Verse 1, 13-16");
  v.push_back("%");
  v.push_back("[V:V1] [GBe]2  e B   | [GBe]2  e B  | [FAc]2 c A  | [FAc]2 c   A  |");
  v.push_back("w:     gotta have my | tools, gotta | have ~ mer- | cu-    ri- al |");
  v.push_back("[V:V2] E,4           | E4           | F,,4        | F,4           |");
  v.push_back("%      E             |              | F#          |               |");
  return v;
}

void ribi::VisualAbcMainDialog::ConvertToPng(const std::string& s)
{
  //Save to file
  {
    std::ofstream f(m_abc_filename.c_str());
    f << s;
  }
  //Convert ABC file to PS
  {
    const std::string cmd = "abcm2ps " + m_abc_filename;
    const int error = std::system(cmd.c_str());
    assert(!error);
    if (error) throw std::runtime_error(cmd.c_str());
  }
  //Convert PS file to PNG or PNGs

  {
    const std::string cmd
      = "convert -density 250 -trim Out.ps "
      + m_png_filename;
    const int error = std::system(cmd.c_str());
    assert(!error);
    if (error) throw std::runtime_error(cmd.c_str());
  }
}

void ribi::VisualAbcMainDialog::ConvertToMid(const std::string& s)
{
  //Save to file
  {
    std::ofstream f(m_abc_filename.c_str());
    f << s;
  }
  //Convert ABC file to midi
  {
    const std::string cmd = "abc2midi "
      + m_abc_filename
      + " -o " + m_mid_filename;
    const int error = std::system(cmd.c_str());
    assert(!error);
    if (error) throw std::runtime_error(cmd.c_str());
  }
}

void ribi::VisualAbcMainDialog::PlayMid()
{
  //Convert ABC file to midi
  {
    const std::string cmd = "playsound "
      + m_mid_filename;
    const int error = std::system(cmd.c_str());
    assert(!error && "playsound not found, type 'sudo apt-get install playmidi'");
    if (error) throw std::runtime_error(cmd.c_str());
  }
}

 

 

 

 

 

./ToolVisualAbc/visualabcmenudialog.h

 

//---------------------------------------------------------------------------
/*
Visual ABC, visual ABC editor
Copyright (C) 2011-2015 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolVisualAbc.htm
//---------------------------------------------------------------------------
#ifndef TOOLVISUALABCMENUDIALOG_H
#define TOOLVISUALABCMENUDIALOG_H

#include "menudialog.h"

namespace ribi {

struct VisualAbcMenuDialog final : public MenuDialog
{
  About GetAbout() const noexcept override;
  Help GetHelp() const noexcept override;
  boost::shared_ptr<const Program> GetProgram() const noexcept override;
  std::string GetVersion() const noexcept override;
  std::vector<std::string> GetVersionHistory() const noexcept override;

  private:
  int ExecuteSpecific(const std::vector<std::string>& argv) noexcept override;

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif
};

} //~namespace ribi

#endif // TOOLVISUALABCMENUDIALOG_H

 

 

 

 

 

./ToolVisualAbc/visualabcmenudialog.cpp

 

//---------------------------------------------------------------------------
/*
Visual ABC, visual ABC editor
Copyright (C) 2011-2015 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolVisualAbc.htm
//---------------------------------------------------------------------------
#include "visualabcmenudialog.h"

#include <cassert>
#include <iostream>

#include "richelbilderbeekprogram.h"
#include "trace.h"
#include "testtimer.h"

int ribi::VisualAbcMenuDialog::ExecuteSpecific(const std::vector<std::string>& argv) noexcept
{
  #ifndef NDEBUG
  Test();
  #endif
  const int argc = static_cast<int>(argv.size());
  if (argc == 1)
  {
    std::cout << GetHelp() << '\n';
    return 1;
  }
  assert(!"TODO");
  return 1;
}

ribi::About ribi::VisualAbcMenuDialog::GetAbout() const noexcept
{
  About a(
    "Richel Bilderbeek",
    "Visual ABC",
    "visual ABC editor",
    "the 5th of May 2011",
    "2011-2015",
    "http://www.richelbilderbeek.nl/ToolVisualAbc.htm",
    GetVersion(),
    GetVersionHistory());
  //a.AddLibrary("Encranger version: " + Encranger::GetVersion());
  //a.AddLibrary("LoopReader version: " + LoopReader<int>::GetVersion());
  return a;
}

ribi::Help ribi::VisualAbcMenuDialog::GetHelp() const noexcept
{
  return Help(
    this->GetAbout().GetFileTitle(),
    this->GetAbout().GetFileDescription(),
    {

    },
    {

    }
  );
}

boost::shared_ptr<const ribi::Program> ribi::VisualAbcMenuDialog::GetProgram() const noexcept
{
  const boost::shared_ptr<const ribi::Program> p {
    new ProgramVisualAbc
  };
  assert(p);
  return p;
}

std::string ribi::VisualAbcMenuDialog::GetVersion() const noexcept
{
  return "1.1";
}

std::vector<std::string> ribi::VisualAbcMenuDialog::GetVersionHistory() const noexcept
{
  return {
    "2011-05-01: Version 1.0: initial version",
    "2011-05-01: Version 1.1: added button to save ABC text"
  };
}

#ifndef NDEBUG
void ribi::VisualAbcMenuDialog::Test() noexcept
{
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  const TestTimer test_timer(__func__,__FILE__,1.0);
}
#endif

 

 

 

 

 

./ToolVisualAbc/zip.sh

 

#!/bin/sh
#zip packs all the files to port into a single .zip file,
#minicking the same folder structure
#Folder structure
# *
#   * Classes
#     * CppAbout
#     * CppQtAboutDialog
#   * Tools
#    * ToolVisualAbc
echo "Mimicking file structure"
mkdir temp_zip
mkdir temp_zip/Classes
mkdir temp_zip/Classes/CppAbout
mkdir temp_zip/Classes/CppQtAboutDialog
mkdir temp_zip/Tools
mkdir temp_zip/Tools/ToolVisualAbc

echo "Copying files"
cp ../../Classes/CppAbout/*.* temp_zip/Classes/CppAbout
cp ../../Classes/CppQtAboutDialog/*.* temp_zip/Classes/CppQtAboutDialog
cp ../../Tools/ToolVisualAbc/*.* temp_zip/Tools/ToolVisualAbc

echo "Compressing files"
cd temp_zip

zip -r ToolVisualAbcSource_1_0 Classes
zip -r ToolVisualAbcSource_1_0 Tools

echo "Copying zipped file from temp folder to this folder"

cd ..
cp temp_zip/ToolVisualAbcSource_1_0.zip ToolVisualAbcSource_1_0.zip

echo "Cleaning up"
#Classes
rm temp_zip/Classes/CppAbout/*.*
rm temp_zip/Classes/CppQtAboutDialog/*.*
rmdir temp_zip/Classes/CppAbout
rmdir temp_zip/Classes/CppQtAboutDialog
rmdir temp_zip/Classes
#Tools
rm temp_zip/Tools/ToolVisualAbc/*.*
rmdir temp_zip/Tools/ToolVisualAbc
rmdir temp_zip/Tools
rm temp_zip/*.*
rmdir temp_zip
echo "Done"

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml