Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) ToolSimMysteryMachine source code (version 1.1)

 

ToolSimMysteryMachine source code (version 1.1).

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ToolSimMysteryMachineDesktop.pro

 

#-------------------------------------------------
#
# Project created by QtCreator 2011-04-09T14:44:16
#
#-------------------------------------------------
QT       += core gui
TARGET = ToolSimMysteryMachineDesktop
TEMPLATE = app

INCLUDEPATH += \
    ../../Classes/CppAbout \
    ../../Classes/CppDial \
    ../../Classes/CppDialWidget \
    ../../Classes/CppLed \
    ../../Classes/CppLedWidget \
    ../../Classes/CppMysteryMachine \
    ../../Classes/CppMysteryMachineWidget \
    ../../Classes/CppQtAboutDialog \
    ../../Classes/CppQtDialWidget \
    ../../Classes/CppQtLedWidget \
    ../../Classes/CppQtMysteryMachineWidget \
    ../../Classes/CppQtToggleButtonWidget \
    ../../Classes/CppRectangle \
    ../../Classes/CppToggleButton \
    ../../Classes/CppToggleButtonWidget \
    ../../Classes/CppTrace \
    ../../Classes/CppWidget

SOURCES += qtmain.cpp\
    qtsimmysterymachinemenudialog.cpp \
    ../../Classes/CppAbout/about.cpp \
    ../../Classes/CppLed/led.cpp \
    ../../Classes/CppMysteryMachine/mysterymachine.cpp \
    ../../Classes/CppQtAboutDialog/qtaboutdialog.cpp \
    ../../Classes/CppQtLedDisplayWidget/qtleddisplaywidget.cpp \
    simmysterymachinemenudialog.cpp \
    ../../Classes/CppMysteryMachineWidget/mysterymachinewidget.cpp \
    ../../Classes/CppWidget/widget.cpp \
    ../../Classes/CppLedWidget/ledwidget.cpp \
    qtsimmysterymachinemaindialog.cpp \
    ../../Classes/CppToggleButton/togglebutton.cpp \
    ../../Classes/CppToggleButtonWidget/togglebuttonwidget.cpp \
    ../../Classes/CppQtMysteryMachineWidget/qtmysterymachinewidget.cpp \
    ../../Classes/CppQtLedWidget/qtledwidget.cpp \
    ../../Classes/CppQtToggleButtonWidget/qttogglebuttonwidget.cpp \
    ../../Classes/CppRectangle/rectangle.cpp \
    ../../Classes/CppQtDialWidget/qtdialwidget.cpp \
    ../../Classes/CppDial/dial.cpp \
    ../../Classes/CppDialWidget/dialwidget.cpp \
    qtsimmysterymachineinstructionsdialog.cpp \
    qtsimmysterymachinerealmachinedialog.cpp

HEADERS  += \
  qtsimmysterymachinemenudialog.h \
  ../../Classes/CppAbout/about.h \
  ../../Classes/CppLed/led.h \
  ../../Classes/CppMysteryMachine/mysterymachine.h \
  ../../Classes/CppQtAboutDialog/qtaboutdialog.h \
  ../../Classes/CppQtLedDisplayWidget/qtleddisplaywidget.h \
    simmysterymachinemenudialog.h \
    ../../Classes/CppMysteryMachineWidget/mysterymachinewidget.h \
    ../../Classes/CppWidget/widget.h \
    ../../Classes/CppLedWidget/ledwidget.h \
    qtsimmysterymachinemaindialog.h \
    ../../Classes/CppToggleButton/togglebutton.h \
    ../../Classes/CppToggleButtonWidget/togglebuttonwidget.h \
    ../../Classes/CppQtMysteryMachineWidget/qtmysterymachinewidget.h \
    ../../Classes/CppQtLedWidget/qtledwidget.h \
    ../../Classes/CppQtToggleButtonWidget/qttogglebuttonwidget.h \
    ../../Classes/CppRectangle/rectangle.h \
    ../../Classes/CppQtDialWidget/qtdialwidget.h \
    ../../Classes/CppDial/dial.h \
    ../../Classes/CppDialWidget/dialwidget.h \
    qtsimmysterymachineinstructionsdialog.h \
    qtsimmysterymachinerealmachinedialog.h

FORMS    += \
  qtsimmysterymachinemenudialog.ui \
  ../../Classes/CppQtAboutDialog/qtaboutdialog.ui \
    qtsimmysterymachinemaindialog.ui \
    qtsimmysterymachineinstructionsdialog.ui \
    qtsimmysterymachinerealmachinedialog.ui

RESOURCES += \
    ToolSimMysteryMachine.qrc

 

 

 

 

 

Qt project file: ToolSimMysteryMachineWebsite.pro

 

#-------------------------------------------------
#
# Project created by QtCreator 2011-04-10T11:16:42
#
#-------------------------------------------------
QT       += core
QT       -= gui
LIBS += -lwt -lwthttp -lboost_program_options
QMAKE_CXXFLAGS += -std=c++0x
TARGET = TestLedWebsite
CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE = app

INCLUDEPATH += \
    ../../Classes/CppAbout \
    ../../Classes/CppDial \
    ../../Classes/CppDialWidget \
    ../../Classes/CppLed \
    ../../Classes/CppLedWidget \
    ../../Classes/CppMysteryMachine \
    ../../Classes/CppMysteryMachineWidget \
    ../../Classes/CppRectangle \
    ../../Classes/CppToggleButton \
    ../../Classes/CppToggleButtonWidget \
    ../../Classes/CppTrace \
    ../../Classes/CppWidget \
    ../../Classes/CppWtAboutDialog \
    ../../Classes/CppWtAutoConfig \
    ../../Classes/CppWtDialWidget \
    ../../Classes/CppWtLedWidget \
    ../../Classes/CppWtLedWidget \
    ../../Classes/CppWtMysteryMachineWidget \
    ../../Classes/CppWtToggleButtonWidget

SOURCES += wtmain.cpp \
    ../../Classes/CppAbout/about.cpp \
    ../../Classes/CppDial/dial.cpp \
    ../../Classes/CppDialWidget/dialwidget.cpp \
    ../../Classes/CppLed/led.cpp \
    ../../Classes/CppLedWidget/ledwidget.cpp \
    ../../Classes/CppMysteryMachine/mysterymachine.cpp \
    ../../Classes/CppMysteryMachineWidget/mysterymachinewidget.cpp \
    ../../Classes/CppRectangle/rectangle.cpp \
    ../../Classes/CppToggleButton/togglebutton.cpp \
    ../../Classes/CppToggleButtonWidget/togglebuttonwidget.cpp \
    ../../Classes/CppWidget/widget.cpp \
    ../../Classes/CppWtAboutDialog/wtaboutdialog.cpp \
    ../../Classes/CppWtAutoConfig/wtautoconfig.cpp \
    ../../Classes/CppWtDialWidget/wtdialwidget.cpp \
    ../../Classes/CppWtLedWidget/wtledwidget.cpp \
    ../../Classes/CppWtMysteryMachineWidget/wtmysterymachinewidget.cpp \
    ../../Classes/CppWtToggleButtonWidget/wttogglebuttonwidget.cpp \
    simmysterymachinemenudialog.cpp \
    wtsimmysterymachinemaindialog.cpp \
    wtsimmysterymachinemenudialog.cpp

HEADERS  += \
    ../../Classes/CppAbout/about.h \
    ../../Classes/CppDial/dial.h \
    ../../Classes/CppDialWidget/dialwidget.h \
    ../../Classes/CppLed/led.h \
    ../../Classes/CppLedWidget/ledwidget.h \
    ../../Classes/CppMysteryMachine/mysterymachine.h \
    ../../Classes/CppMysteryMachineWidget/mysterymachinewidget.h \
    ../../Classes/CppRectangle/rectangle.h \
    ../../Classes/CppToggleButton/togglebutton.h \
    ../../Classes/CppToggleButtonWidget/togglebuttonwidget.h \
    ../../Classes/CppTrace/trace.h \
    ../../Classes/CppWidget/widget.h \
    ../../Classes/CppWtAboutDialog/wtaboutdialog.h \
    ../../Classes/CppWtAutoConfig/wtautoconfig.h \
    ../../Classes/CppWtDialWidget/wtdialwidget.h \
    ../../Classes/CppWtLedWidget/wtledwidget.h \
    ../../Classes/CppWtMysteryMachineWidget/wtmysterymachinewidget.h \
    ../../Classes/CppWtMysteryMachineWidget/wtmysterymachinewidget.h \
    ../../Classes/CppWtToggleButtonWidget/wttogglebuttonwidget.h \
    simmysterymachinemenudialog.h \
    wtsimmysterymachinemaindialog.h \
    wtsimmysterymachinemenudialog.h

RESOURCES += \
    ToolSimMysteryMachine.qrc

 

 

 

 

 

qtmain.cpp

 

//---------------------------------------------------------------------------
#include <QtGui/QApplication>
#include "qtsimmysterymachinemenudialog.h"
#include "trace.h"
//---------------------------------------------------------------------------
int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  START_TRACE();
  QtSimMysteryMachineMenuDialog w;
  w.show();
  return a.exec();
}
//---------------------------------------------------------------------------

 

 

 

 

 

qtsimmysterymachineinstructionsdialog.h

 

#ifndef QTSIMMYSTERYMACHINEINSTRUCTIONSDIALOG_H
#define QTSIMMYSTERYMACHINEINSTRUCTIONSDIALOG_H

#include <QDialog>

namespace Ui {
    class QtSimMysteryMachineInstructionsDialog;
}

class QtSimMysteryMachineInstructionsDialog : public QDialog
{
    Q_OBJECT

public:
    explicit QtSimMysteryMachineInstructionsDialog(QWidget *parent = 0);
    ~QtSimMysteryMachineInstructionsDialog();

private:
    Ui::QtSimMysteryMachineInstructionsDialog *ui;
};

#endif // QTSIMMYSTERYMACHINEINSTRUCTIONSDIALOG_H

 

 

 

 

 

qtsimmysterymachineinstructionsdialog.cpp

 

#include "qtsimmysterymachineinstructionsdialog.h"
#include "ui_qtsimmysterymachineinstructionsdialog.h"

QtSimMysteryMachineInstructionsDialog::QtSimMysteryMachineInstructionsDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::QtSimMysteryMachineInstructionsDialog)
{
    ui->setupUi(this);
}

QtSimMysteryMachineInstructionsDialog::~QtSimMysteryMachineInstructionsDialog()
{
    delete ui;
}

 

 

 

 

 

qtsimmysterymachinemaindialog.h

 

#ifndef QTMYSTERYMACHINEDIALOG_H
#define QTMYSTERYMACHINEDIALOG_H
//---------------------------------------------------------------------------
#include <boost/scoped_ptr.hpp>
//---------------------------------------------------------------------------
#include <QDialog>
//---------------------------------------------------------------------------
namespace Ui {
  class QtSimMysteryMachineMainDialog;
}
//---------------------------------------------------------------------------
struct QtMysteryMachineWidget;
//---------------------------------------------------------------------------
class QtSimMysteryMachineMainDialog : public QDialog
{
  Q_OBJECT

public:
  explicit QtSimMysteryMachineMainDialog(QWidget *parent = 0);
  ~QtSimMysteryMachineMainDialog();

protected:
  void changeEvent(QEvent *e);

private:
  Ui::QtSimMysteryMachineMainDialog *ui;
  boost::scoped_ptr<QtMysteryMachineWidget> m_machine;

private slots:
};
//---------------------------------------------------------------------------
#endif // QTMYSTERYMACHINEDIALOG_H

 

 

 

 

 

qtsimmysterymachinemaindialog.cpp

 

//---------------------------------------------------------------------------
#include <iostream>
//---------------------------------------------------------------------------
#include <boost/lexical_cast.hpp>
//---------------------------------------------------------------------------
#include "dial.h"
#include "dialwidget.h"
#include "led.h"
#include "ledwidget.h"
#include "mysterymachine.h"
#include "mysterymachinewidget.h"
#include "qtmysterymachinewidget.h"
#include "qtsimmysterymachinemaindialog.h"
#include "togglebutton.h"
#include "togglebuttonwidget.h"
#include "ui_qtsimmysterymachinemaindialog.h"
//---------------------------------------------------------------------------
QtSimMysteryMachineMainDialog::QtSimMysteryMachineMainDialog(QWidget *parent)
: QDialog(parent),
   ui(new Ui::QtSimMysteryMachineMainDialog),
   m_machine(new QtMysteryMachineWidget)
{
  ui->setupUi(this);

  ui->my_layout->addWidget(m_machine.get());
}
//---------------------------------------------------------------------------
QtSimMysteryMachineMainDialog::~QtSimMysteryMachineMainDialog()
{
  delete ui;
}
//---------------------------------------------------------------------------
void QtSimMysteryMachineMainDialog::changeEvent(QEvent *e)
{
  QDialog::changeEvent(e);
  switch (e->type()) {
  case QEvent::LanguageChange:
    ui->retranslateUi(this);
    break;
  default:
    break;
  }
}
//---------------------------------------------------------------------------

 

 

 

 

 

qtsimmysterymachinemenudialog.h

 

#ifndef QTSIMMYSTERYMACHINEMENUDIALOG_H
#define QTSIMMYSTERYMACHINEMENUDIALOG_H
//---------------------------------------------------------------------------
#include <QDialog>
//---------------------------------------------------------------------------
namespace Ui {
  class QtSimMysteryMachineMenuDialog;
}
//---------------------------------------------------------------------------
class QtSimMysteryMachineMenuDialog : public QDialog
{
  Q_OBJECT

public:
  explicit QtSimMysteryMachineMenuDialog(QWidget *parent = 0);
  ~QtSimMysteryMachineMenuDialog();

protected:
  void changeEvent(QEvent *e);

private:
  Ui::QtSimMysteryMachineMenuDialog *ui;

private slots:
    void on_button_start_clicked();
    void on_button_about_clicked();
    void on_button_quit_clicked();
    void on_button_instructions_clicked();
    void on_button_real_clicked();
};
//---------------------------------------------------------------------------
#endif // QTSIMMYSTERYMACHINEMENUDIALOG_H

 

 

 

 

 

qtsimmysterymachinemenudialog.cpp

 

//---------------------------------------------------------------------------
#include "dial.h"
#include "led.h"
#include "qtaboutdialog.h"
#include "qtdialwidget.h"
#include "qtledwidget.h"
#include "qtmysterymachinewidget.h"
#include "qtsimmysterymachineinstructionsdialog.h"
#include "qtsimmysterymachinemaindialog.h"
#include "qtsimmysterymachinemenudialog.h"
#include "qtsimmysterymachinerealmachinedialog.h"
#include "qttogglebuttonwidget.h"
#include "simmysterymachinemenudialog.h"
#include "ui_qtsimmysterymachinemenudialog.h"
//---------------------------------------------------------------------------
QtSimMysteryMachineMenuDialog::QtSimMysteryMachineMenuDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::QtSimMysteryMachineMenuDialog)
{
  ui->setupUi(this);

  ui->led_1->GetWidget()->GetLed()->SetColor(255,255,255);
  ui->led_2->GetWidget()->GetLed()->SetColor(255,  0,  0);
  ui->led_3->GetWidget()->GetLed()->SetColor(  0,255,  0);
  ui->led_4->GetWidget()->GetLed()->SetColor(  0,  0,255);
  ui->led_5->GetWidget()->GetLed()->SetColor(  0,  0,  0);
  const int size = ui->button_about->height() + 8;
  ui->led_1->GetWidget()->SetGeometry(Rect(0,0,size,size));
  ui->led_2->GetWidget()->SetGeometry(Rect(0,0,size,size));
  ui->led_3->GetWidget()->SetGeometry(Rect(0,0,size,size));
  ui->led_4->GetWidget()->SetGeometry(Rect(0,0,size,size));
  ui->led_5->GetWidget()->SetGeometry(Rect(0,0,size,size));

}
//---------------------------------------------------------------------------
QtSimMysteryMachineMenuDialog::~QtSimMysteryMachineMenuDialog()
{
  delete ui;
}
//---------------------------------------------------------------------------
void QtSimMysteryMachineMenuDialog::changeEvent(QEvent *e)
{
  QDialog::changeEvent(e);
  switch (e->type()) {
  case QEvent::LanguageChange:
    ui->retranslateUi(this);
    break;
  default:
    break;
  }
}
//---------------------------------------------------------------------------
void QtSimMysteryMachineMenuDialog::on_button_start_clicked()
{
  this->hide();
  QtSimMysteryMachineMainDialog d;
  d.exec();
  this->show();
}
//---------------------------------------------------------------------------
void QtSimMysteryMachineMenuDialog::on_button_about_clicked()
{
  this->hide();
  About a = SimMysteryMachineMenuDialog::GetAbout();
  a.AddLibrary("QtDialWidget version: " + QtDialWidget::GetVersion());
  a.AddLibrary("QtLedWidget version: " + QtLedWidget::GetVersion());
  a.AddLibrary("QtMysteryMachineWidget version: " + QtMysteryMachineWidget::GetVersion());
  a.AddLibrary("QtToggleButtonWidget version: " + QtToggleButtonWidget::GetVersion());
  QtAboutDialog d(a);
  d.exec();
  this->show();
}
//---------------------------------------------------------------------------
void QtSimMysteryMachineMenuDialog::on_button_quit_clicked()
{
  this->close();
}
//---------------------------------------------------------------------------
void QtSimMysteryMachineMenuDialog::on_button_instructions_clicked()
{
  this->hide();
  QtSimMysteryMachineInstructionsDialog d;
  d.exec();
  this->show();
}
//---------------------------------------------------------------------------
void QtSimMysteryMachineMenuDialog::on_button_real_clicked()
{
  this->hide();
  QtSimMysteryMachineRealMachineDialog d;
  d.exec();
  this->show();
}
//---------------------------------------------------------------------------

 

 

 

 

 

qtsimmysterymachinerealmachinedialog.h

 

#ifndef QTSIMMYSTERYMACHINEREALMACHINEDIALOG_H
#define QTSIMMYSTERYMACHINEREALMACHINEDIALOG_H

#include <QDialog>

namespace Ui {
    class QtSimMysteryMachineRealMachineDialog;
}

class QtSimMysteryMachineRealMachineDialog : public QDialog
{
    Q_OBJECT

public:
    explicit QtSimMysteryMachineRealMachineDialog(QWidget *parent = 0);
    ~QtSimMysteryMachineRealMachineDialog();

private:
    Ui::QtSimMysteryMachineRealMachineDialog *ui;
};

#endif // QTSIMMYSTERYMACHINEREALMACHINEDIALOG_H

 

 

 

 

 

qtsimmysterymachinerealmachinedialog.cpp

 

#include "qtsimmysterymachinerealmachinedialog.h"
#include "ui_qtsimmysterymachinerealmachinedialog.h"

QtSimMysteryMachineRealMachineDialog::QtSimMysteryMachineRealMachineDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::QtSimMysteryMachineRealMachineDialog)
{
    ui->setupUi(this);
}

QtSimMysteryMachineRealMachineDialog::~QtSimMysteryMachineRealMachineDialog()
{
    delete ui;
}

 

 

 

 

 

simmysterymachinemenudialog.h

 

#ifndef SIMMYSTERYMACHINEMENUDIALOG_H
#define SIMMYSTERYMACHINEMENUDIALOG_H
//---------------------------------------------------------------------------
#include "about.h"
//---------------------------------------------------------------------------
struct SimMysteryMachineMenuDialog
{
  SimMysteryMachineMenuDialog();
  static const About GetAbout();
  static const std::string GetVersion();
  static const std::vector<std::string> GetVersionHistory();
};
//---------------------------------------------------------------------------
#endif // SIMMYSTERYMACHINEMENUDIALOG_H

 

 

 

 

 

simmysterymachinemenudialog.cpp

 

//---------------------------------------------------------------------------
#include "dial.h"
#include "dialwidget.h"
#include "led.h"
#include "ledwidget.h"
#include "mysterymachine.h"
#include "mysterymachinewidget.h"
#include "simmysterymachinemenudialog.h"
#include "togglebutton.h"
#include "togglebuttonwidget.h"
#include "widget.h"
//---------------------------------------------------------------------------
const About SimMysteryMachineMenuDialog::GetAbout()
{
  About a(
    "Richel Bilderbeek",
    "SimMysteryMachine",
    "simulator of my mystery machine",
    "the 15th of September 2011",
    "2011",
    "http://www.richelbilderbeek.nl/ToolSimMysteryMachine.htm",
    GetVersion(),
    GetVersionHistory());
  a.AddLibrary("Dial version: " + Dial::GetVersion());
  a.AddLibrary("DialWidget version: " + DialWidget::GetVersion());
  a.AddLibrary("Led version: " + Led::GetVersion());
  a.AddLibrary("LedWidget version: " + LedWidget::GetVersion());
  a.AddLibrary("ToggleButton version: " + ToggleButton::GetVersion());
  a.AddLibrary("ToggleButtonWidget version: " + ToggleButtonWidget::GetVersion());
  a.AddLibrary("MysteryMachine version: " + MysteryMachine::GetVersion());
  a.AddLibrary("MysteryMachineWidget version: " + MysteryMachineWidget::GetVersion());
  a.AddLibrary("Widget version: " + Widget::GetVersion());
  return a;
}
//---------------------------------------------------------------------------
const std::string SimMysteryMachineMenuDialog::GetVersion()
{
  return "1.1";
}
//---------------------------------------------------------------------------
const std::vector<std::string> SimMysteryMachineMenuDialog::GetVersionHistory()
{
  std::vector<std::string> v;
  v.push_back("2011-04-10: Version 1.0: initial version (web application version not working yet)");
  v.push_back("2011-09-15: Version 1.1: working web application, added picture of a real MysteryMachine");
  return v;
}
//---------------------------------------------------------------------------

 

 

 

 

 

wtmain.cpp

 

//---------------------------------------------------------------------------
/*
TestLed, tool to test the Led class
Copyright (C) 2011 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/ToolTestLed.htm
//---------------------------------------------------------------------------
#include <Wt/WApplication>
#include <Wt/WEnvironment>
//---------------------------------------------------------------------------
#include "trace.h"
#include "wtautoconfig.h"
#include "wtsimmysterymachinemenudialog.h"
//---------------------------------------------------------------------------
struct WtApplication : public Wt::WApplication
{
  WtApplication(const Wt::WEnvironment& env)
    : Wt::WApplication(env)
  {
    this->setTitle("SimMysteryMachine");
    this->useStyleSheet("wt.css");
    root()->addWidget(new WtSimMysteryMachineMenuDialog);
  }
};
//---------------------------------------------------------------------------
Wt::WApplication *createApplication(
  const Wt::WEnvironment& env)
{
  return new WtApplication(env);
}
//---------------------------------------------------------------------------
int main(int argc, char **argv)
{
  START_TRACE();
  WtAutoConfig::SaveDefaultStylesheet();
  WtAutoConfig a(argc,argv,createApplication);
  return a.Run();
}
//---------------------------------------------------------------------------

 

 

 

 

 

wtsimmysterymachinemaindialog.h

 

//---------------------------------------------------------------------------
#ifndef WTMYSTERYMACHINEDIALOG_H
#define WTMYSTERYMACHINEDIALOG_H
//---------------------------------------------------------------------------
#include <boost/scoped_ptr.hpp>
#include <boost/signals2.hpp>
//---------------------------------------------------------------------------
#include <Wt/WContainerWidget>
#include <Wt/WLineEdit>
//---------------------------------------------------------------------------
struct WtMysteryMachineWidget;
//---------------------------------------------------------------------------
///WtSimMysteryMachineMainDialog displays a
///WtMysteryMachineWidget
struct WtSimMysteryMachineMainDialog : public Wt::WContainerWidget
{
  WtSimMysteryMachineMainDialog();

  private:

  ///The user interface
  struct Ui
  {
    Ui();
    WtMysteryMachineWidget * const m_machine;
  } ui;
};
//---------------------------------------------------------------------------
#endif // WTMYSTERYMACHINEDIALOG_H

 

 

 

 

 

wtsimmysterymachinemaindialog.cpp

 

//---------------------------------------------------------------------------
/*
TestLed, tool to test the Led class
Copyright (C) 2011 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/ToolTestLed.htm
//---------------------------------------------------------------------------
#include <algorithm>
#include <cassert>
#include <iterator>
#include <string>
#include <sstream>
#include <vector>
//---------------------------------------------------------------------------
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/numeric/conversion/cast.hpp>
//---------------------------------------------------------------------------
#include <Wt/WBreak>
#include <Wt/WLabel>
#include <Wt/WPushButton>
#include <Wt/WTextArea>
//---------------------------------------------------------------------------
#include "about.h"
#include "dial.h"
#include "dialwidget.h"
#include "led.h"
#include "ledwidget.h"
#include "mysterymachine.h"
#include "mysterymachinewidget.h"
#include "togglebutton.h"
#include "togglebuttonwidget.h"
#include "trace.h"
#include "wtaboutdialog.h"
#include "wtdialwidget.h"
#include "wtsimmysterymachinemaindialog.h"
#include "wtmysterymachinewidget.h"
//---------------------------------------------------------------------------
WtSimMysteryMachineMainDialog::Ui::Ui()
: m_machine(new WtMysteryMachineWidget(300,600))
{

}
//---------------------------------------------------------------------------
WtSimMysteryMachineMainDialog::WtSimMysteryMachineMainDialog()
{
  setContentAlignment(Wt::AlignCenter);
  addWidget(ui.m_machine);
}
//---------------------------------------------------------------------------

 

 

 

 

 

wtsimmysterymachinemenudialog.h

 


//---------------------------------------------------------------------------
#ifndef WTSIMMYSTERYMACHINEMENUDIALOG_H
#define WTSIMMYSTERYMACHINEMENUDIALOG_H
//---------------------------------------------------------------------------
#include <Wt/WContainerWidget>
//---------------------------------------------------------------------------
struct WtSimMysteryMachineMenuDialog : public Wt::WContainerWidget
{
  WtSimMysteryMachineMenuDialog();

  private:
  Wt::WWidget * CreateNewAboutDialog() const;
  Wt::WWidget * CreateNewMainDialog() const;
  Wt::WWidget * CreateNewWelcomeDialog() const;
};
//---------------------------------------------------------------------------
#endif // WTSIMMYSTERYMACHINEMENUDIALOG_H

 

 

 

 

 

wtsimmysterymachinemenudialog.cpp

 

//---------------------------------------------------------------------------
/*
TestLed, tool to test the Led class
Copyright (C) 2011 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/ToolTestLed.htm
//---------------------------------------------------------------------------
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/numeric/conversion/cast.hpp>
//---------------------------------------------------------------------------
#include <Wt/WBreak>
#include <Wt/WGroupBox>
#include <Wt/WImage>
#include <Wt/WLabel>
#include <Wt/WPushButton>
#include <Wt/WStackedWidget>
#include <Wt/WMenu>
#include <Wt/WMenuItem>
//---------------------------------------------------------------------------
#include "about.h"
#include "simmysterymachinemenudialog.h"
#include "wtaboutdialog.h"
#include "wtautoconfig.h"
#include "wtdialwidget.h"
#include "wtledwidget.h"
#include "wtmysterymachinewidget.h"
#include "wtsimmysterymachinemaindialog.h"
#include "wtsimmysterymachinemenudialog.h"
#include "wttogglebuttonwidget.h"
//---------------------------------------------------------------------------
#include <QFile>
//---------------------------------------------------------------------------
WtSimMysteryMachineMenuDialog::WtSimMysteryMachineMenuDialog()
{
  {
    std::vector<std::string> image_names;
    image_names.push_back("ToolSimMysteryMachine.png");
    image_names.push_back("ToolSimMysteryMachineWelcome.png");

    BOOST_FOREACH(const std::string& filename,image_names)
    {
      if (!(QFile::exists(filename.c_str())))
      {
        QFile f( (std::string(":/images/") + filename).c_str() );
        f.copy(filename.c_str());
      }
      if (!boost::filesystem::exists(filename.c_str()))
      {
        std::cerr << "File not found: " << filename << '\n';
      }
      assert(boost::filesystem::exists(filename.c_str()));
    }
  }
  this->setContentAlignment(Wt::AlignCenter);
  {
    Wt::WLabel * const title = new Wt::WLabel("SimMysteryMachine");
    title->setStyleClass("title");
    this->addWidget(title);
  }
  //Menu
  {
    Wt::WStackedWidget * const contents = new Wt::WStackedWidget;
    Wt::WMenu * const menu = new Wt::WMenu(contents,Wt::Horizontal);
    //Using CSS styleclass is the best (only?) way to display the menu well
    menu->setStyleClass("menu");
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "Welcome",
        CreateNewWelcomeDialog());
      menu->addItem(item);
    }
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "Start",
        CreateNewMainDialog());
      menu->addItem(item);
    }
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "About",
        CreateNewAboutDialog());
      menu->addItem(item);
    }
    //Display menu on top
    this->addWidget(menu);
    this->addWidget(new Wt::WBreak);
    //Display contents below menu
    this->addWidget(contents);
  }
}
//---------------------------------------------------------------------------
Wt::WWidget * WtSimMysteryMachineMenuDialog::CreateNewAboutDialog() const
{
  About a = SimMysteryMachineMenuDialog::GetAbout();
  a.AddLibrary("WtAutoConfig version: " + WtAutoConfig::GetVersion());
  a.AddLibrary("WtDialWidget version: " + WtDialWidget::GetVersion());
  a.AddLibrary("WtLedWidget version: " + WtLedWidget::GetVersion());
  a.AddLibrary("WtMysteryMachineWidget version: " + WtMysteryMachineWidget::GetVersion());
  a.AddLibrary("WtToggleButtonWidget version: " + WtToggleButtonWidget::GetVersion());
  WtAboutDialog * const d = new WtAboutDialog(a,false);
  assert(d);
  return d;
}
//---------------------------------------------------------------------------
Wt::WWidget * WtSimMysteryMachineMenuDialog::CreateNewMainDialog() const
{
  WtSimMysteryMachineMainDialog * const d = new WtSimMysteryMachineMainDialog;
  assert(d);
  return d;
}
//---------------------------------------------------------------------------
Wt::WWidget * WtSimMysteryMachineMenuDialog::CreateNewWelcomeDialog() const
{
  Wt::WContainerWidget * dialog = new Wt::WContainerWidget;
  dialog->setContentAlignment(Wt::AlignCenter);
  dialog->addWidget(new Wt::WBreak);
  new Wt::WLabel("Welcome to SimMysteryMachine",dialog);
  new Wt::WBreak(dialog);
  new Wt::WBreak(dialog);
  new Wt::WLabel("SimMysteryMachine is a simulation of a machine",dialog);
  new Wt::WBreak(dialog);
  new Wt::WLabel("I designed and built.",dialog);
  new Wt::WBreak(dialog);
  new Wt::WBreak(dialog);
  new Wt::WLabel("What it does? That's a mystery...",dialog);
  new Wt::WBreak(dialog);
  new Wt::WBreak(dialog);
  {
    Wt::WGroupBox * const box = new Wt::WGroupBox("Explanation",dialog);
    box->addWidget(new Wt::WImage("ToolSimMysteryMachineWelcome.png"));
  }
  new Wt::WBreak(dialog);
  new Wt::WBreak(dialog);
  {
    Wt::WGroupBox * const box = new Wt::WGroupBox("The real MysteryMachine (prototype)",dialog);
    box->addWidget(new Wt::WImage("ToolSimMysteryMachine.png"));
  }
  return dialog;
}
//---------------------------------------------------------------------------

 

 

 

 

 

crosscompiletowindows.sh

 

#!/bin/sh
#From http://richelbilderbeek.nl/CppQtCrosscompileToWindowsExample15.htm

echo "Cross compiling to Windows"

echo "1/2: Creating Windows makefile"
i686-pc-mingw32-qmake ToolSimMysteryMachineDesktop.pro

echo "2/2: making makefile"

make

echo "Done"

 

 

 

 

 

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
#     * CppDial
#     * CppDialWidget
#     * CppLed
#     * CppLedWidget
#     * CppMysteryMachine
#     * CppMysteryMachineWidget
#     * CppQtAboutDialog
#     * CppQtDialWidget
#     * CppQtLedDisplayWidget
#     * CppQtLedWidget
#     * CppQtMysteryMachineWidget
#     * CppQtToggleButtonWidget
#     * CppRectangle
#     * CppToggleButton
#     * CppToggleButtonWidget
#     * CppTrace
#     * CppWidget
#     * CppWtAboutDialog
#     * CppWtAutoConfig
#     * CppWtDialWidget
#     * CppWtLedWidget
#     * CppWtMysteryMachineWidget
#     * CppWtToggleButtonWidget
#   * Tools
#    * ToolSimMysteryMachine

FOLDERNAME=ToolSimMysteryMachine
FILENAME=$FOLDERNAME"Source_1_1"
ZIP_FILENAME=$FILENAME".zip"
HTM_FILENAME=$FILENAME".htm"

rm *.user
rm $ZIP_FILENAME
rm $HTM_FILENAME

echo "Mimicking file structure"
mkdir temp_zip
mkdir temp_zip/Classes
mkdir temp_zip/Classes/CppAbout
mkdir temp_zip/Classes/CppDial
mkdir temp_zip/Classes/CppDialWidget
mkdir temp_zip/Classes/CppLed
mkdir temp_zip/Classes/CppLedWidget
mkdir temp_zip/Classes/CppMysteryMachine
mkdir temp_zip/Classes/CppMysteryMachineWidget
mkdir temp_zip/Classes/CppQtAboutDialog
mkdir temp_zip/Classes/CppQtDialWidget
mkdir temp_zip/Classes/CppQtLedDisplayWidget
mkdir temp_zip/Classes/CppQtLedWidget
mkdir temp_zip/Classes/CppQtMysteryMachineWidget
mkdir temp_zip/Classes/CppQtToggleButtonWidget
mkdir temp_zip/Classes/CppRectangle
mkdir temp_zip/Classes/CppToggleButton
mkdir temp_zip/Classes/CppToggleButtonWidget
mkdir temp_zip/Classes/CppTrace
mkdir temp_zip/Classes/CppWidget
mkdir temp_zip/Classes/CppWtAboutDialog
mkdir temp_zip/Classes/CppWtAutoConfig
mkdir temp_zip/Classes/CppWtDialWidget
mkdir temp_zip/Classes/CppWtLedWidget
mkdir temp_zip/Classes/CppWtMysteryMachineWidget
mkdir temp_zip/Classes/CppWtToggleButtonWidget
mkdir temp_zip/Tools
mkdir temp_zip/Tools/ToolSimMysteryMachine

echo "Copying files"
cp ../../Classes/CppAbout/*.* temp_zip/Classes/CppAbout
cp ../../Classes/CppDial/*.* temp_zip/Classes/CppDial
cp ../../Classes/CppDialWidget/*.* temp_zip/Classes/CppDialWidget
cp ../../Classes/CppLed/*.* temp_zip/Classes/CppLed
cp ../../Classes/CppLedWidget/*.* temp_zip/Classes/CppLedWidget
cp ../../Classes/CppMysteryMachine/*.* temp_zip/Classes/CppMysteryMachine
cp ../../Classes/CppMysteryMachineWidget/*.* temp_zip/Classes/CppMysteryMachineWidget
cp ../../Classes/CppQtAboutDialog/*.* temp_zip/Classes/CppQtAboutDialog
cp ../../Classes/CppQtDialWidget/*.* temp_zip/Classes/CppQtDialWidget
cp ../../Classes/CppQtLedDisplayWidget/*.* temp_zip/Classes/CppQtLedDisplayWidget
cp ../../Classes/CppQtLedWidget/*.* temp_zip/Classes/CppQtLedWidget
cp ../../Classes/CppQtMysteryMachineWidget/*.* temp_zip/Classes/CppQtMysteryMachineWidget
cp ../../Classes/CppQtToggleButtonWidget/*.* temp_zip/Classes/CppQtToggleButtonWidget
cp ../../Classes/CppRectangle/*.* temp_zip/Classes/CppRectangle
cp ../../Classes/CppToggleButton/*.* temp_zip/Classes/CppToggleButton
cp ../../Classes/CppToggleButtonWidget/*.* temp_zip/Classes/CppToggleButtonWidget
cp ../../Classes/CppTrace/*.* temp_zip/Classes/CppTrace
cp ../../Classes/CppWidget/*.* temp_zip/Classes/CppWidget
cp ../../Classes/CppWtAboutDialog/*.* temp_zip/Classes/CppWtAboutDialog
cp ../../Classes/CppWtAutoConfig/*.* temp_zip/Classes/CppWtAutoConfig
cp ../../Classes/CppWtDialWidget/*.* temp_zip/Classes/CppWtDialWidget
cp ../../Classes/CppWtLedWidget/*.* temp_zip/Classes/CppWtLedWidget
cp ../../Classes/CppWtMysteryMachineWidget/*.* temp_zip/Classes/CppWtMysteryMachineWidget
cp ../../Classes/CppWtToggleButtonWidget/*.* temp_zip/Classes/CppWtToggleButtonWidget
cp ../../Tools/ToolSimMysteryMachine/*.* temp_zip/Tools/ToolSimMysteryMachine

#echo "Compressing files"
cd temp_zip
zip -r $FILENAME Classes
#zip -r $FILENAME Libraries
#zip -r $FILENAME Projects
zip -r $FILENAME Tools
cd ..
cp "temp_zip/"$ZIP_FILENAME $ZIP_FILENAME

echo "Cleaning up"

#Classes
rm temp_zip/Classes/CppAbout/*.*
rm temp_zip/Classes/CppDial/*.*
rm temp_zip/Classes/CppDialWidget/*.*
rm temp_zip/Classes/CppLed/*.*
rm temp_zip/Classes/CppLedWidget/*.*
rm temp_zip/Classes/CppMysteryMachine/*.*
rm temp_zip/Classes/CppMysteryMachineWidget/*.*
rm temp_zip/Classes/CppQtAboutDialog/*.*
rm temp_zip/Classes/CppQtDialWidget/*.*
rm temp_zip/Classes/CppQtLedDisplayWidget/*.*
rm temp_zip/Classes/CppQtLedWidget/*.*
rm temp_zip/Classes/CppQtMysteryMachineWidget/*.*
rm temp_zip/Classes/CppQtToggleButtonWidget/*.*
rm temp_zip/Classes/CppRectangle/*.*
rm temp_zip/Classes/CppToggleButton/*.*
rm temp_zip/Classes/CppToggleButtonWidget/*.*
rm temp_zip/Classes/CppTrace/*.*
rm temp_zip/Classes/CppWidget/*.*
rm temp_zip/Classes/CppWtAboutDialog/*.*
rm temp_zip/Classes/CppWtAutoConfig/*.*
rm temp_zip/Classes/CppWtDialWidget/*.*
rm temp_zip/Classes/CppWtLedWidget/*.*
rm temp_zip/Classes/CppWtMysteryMachineWidget/*.*
rm temp_zip/Classes/CppWtToggleButtonWidget/*.*
rmdir temp_zip/Classes/CppAbout
rmdir temp_zip/Classes/CppDial
rmdir temp_zip/Classes/CppDialWidget
rmdir temp_zip/Classes/CppLed
rmdir temp_zip/Classes/CppLedWidget
rmdir temp_zip/Classes/CppMysteryMachine
rmdir temp_zip/Classes/CppMysteryMachineWidget
rmdir temp_zip/Classes/CppQtAboutDialog
rmdir temp_zip/Classes/CppQtDialWidget
rmdir temp_zip/Classes/CppQtLedDisplayWidget
rmdir temp_zip/Classes/CppQtLedWidget
rmdir temp_zip/Classes/CppQtMysteryMachineWidget
rmdir temp_zip/Classes/CppQtToggleButtonWidget
rmdir temp_zip/Classes/CppRectangle
rmdir temp_zip/Classes/CppToggleButton
rmdir temp_zip/Classes/CppToggleButtonWidget
rmdir temp_zip/Classes/CppTrace
rmdir temp_zip/Classes/CppWidget
rmdir temp_zip/Classes/CppWtAboutDialog
rmdir temp_zip/Classes/CppWtAutoConfig
rmdir temp_zip/Classes/CppWtDialWidget
rmdir temp_zip/Classes/CppWtLedWidget
rmdir temp_zip/Classes/CppWtMysteryMachineWidget
rmdir temp_zip/Classes/CppWtToggleButtonWidget
rmdir temp_zip/Classes

#Tools
rm temp_zip/Tools/ToolSimMysteryMachine/*.*
rmdir temp_zip/Tools/ToolSimMysteryMachine
rmdir temp_zip/Tools
rm temp_zip/*.*
rmdir temp_zip
echo "Done"

../ToolCodeToHtmlConsole-build-desktop/codetohtml --source "../"$FOLDERNAME
cp $FOLDERNAME".htm" $HTM_FILENAME
rm $FOLDERNAME".htm"

 

 

 

 

 

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