Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) TestQtRoundedRectItem

 

TestQtRoundedRectItem is a tool to test my QtRoundedRectItem class.

 

 

 

 

 

Downloads

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./ToolTestQtRoundedRectItem/ToolTestQtRoundedRectItemDesktop.pro

 

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

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

include(../../Classes/CppContainer/CppContainer.pri)
include(../../Classes/CppCounter/CppCounter.pri)
include(../../Classes/CppGeometry/CppGeometry.pri)
include(../../Classes/CppPlane/CppPlane.pri)
include(../../Classes/CppRibiRandom/CppRibiRandom.pri)
include(../../Classes/CppRibiRegex/CppRibiRegex.pri)
include(../../Classes/CppQtKeyboardFriendlyGraphicsView/CppQtKeyboardFriendlyGraphicsView.pri)
include(../../Classes/CppQtRoundedRectItem/CppQtRoundedRectItem.pri)
#include(../../Classes/CppQtRoundedEditRectItem/CppQtRoundedEditRectItem.pri)
#include(../../Classes/CppQtRoundedTextRectItem/CppQtRoundedTextRectItem.pri)

include(ToolTestQtRoundedRectItemDesktop.pri)

SOURCES += qtmain.cpp

 

 

 

 

 

./ToolTestQtRoundedRectItem/ToolTestQtRoundedRectItemConsole.pri

 

INCLUDEPATH += \
    ../../Tools/ToolTestQtRoundedRectItem

SOURCES += \
    ../../Tools/ToolTestQtRoundedRectItem/testqtroundedrectitemmenudialog.cpp

HEADERS += \
    ../../Tools/ToolTestQtRoundedRectItem/testqtroundedrectitemmenudialog.h

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

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

 

 

 

 

 

./ToolTestQtRoundedRectItem/ToolTestQtRoundedRectItemDesktop.pri

 

include(../../Tools/ToolTestQtRoundedRectItem/ToolTestQtRoundedRectItemConsole.pri)

HEADERS += \
    ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemwidget.h \
    ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmenudialog.h \
    ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemcomparedialog.h \
    ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmodifydialog.h

SOURCES += \
    ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemwidget.cpp \
    ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmenudialog.cpp \
    ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemcomparedialog.cpp \
    ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmodifydialog.cpp

FORMS += \
    ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmenudialog.ui \
    ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemcomparedialog.ui \
    ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmodifydialog.ui

 

 

 

 

 

./ToolTestQtRoundedRectItem/ToolTestQtRoundedRectItemWebsite.pri

 

include(../../Tools/ToolTestQtRoundedRectItem/ToolTestQtRoundedRectItemConsole.pri)

 

 

 

 

 

./ToolTestQtRoundedRectItem/qtmain.cpp

 

//---------------------------------------------------------------------------
/*
TestQtRoundedRectItem, tool to test QtRoundedRectItem
Copyright (C) 2012-2014  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/ToolTestQtRoundedRectItem.htm
//---------------------------------------------------------------------------
#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 <QApplication>
#include "qttestqtroundedrectitemmenudialog.h"
#pragma GCC diagnostic pop

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

 

 

 

 

 

./ToolTestQtRoundedRectItem/qttestqtroundedrectitemcomparedialog.h

 

//---------------------------------------------------------------------------
/*
TestQtRoundedRectItem, tool to test QtRoundedRectItem
Copyright (C) 2012-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/ToolTestQtRoundedRectItem.htm
//---------------------------------------------------------------------------
#ifndef QTTESTQTROUNDEDRECTITEMCOMPAREDIALOG_H
#define QTTESTQTROUNDEDRECTITEMCOMPAREDIALOG_H

#include "qthideandshowdialog.h"

namespace Ui {
class QtTestQtRoundedRectItemCompareDialog;
}

namespace ribi {

class QtTestQtRoundedRectItemCompareDialog : public QtHideAndShowDialog
{
  Q_OBJECT
    
public:

  explicit QtTestQtRoundedRectItemCompareDialog(QWidget *parent = 0);
  QtTestQtRoundedRectItemCompareDialog(const QtTestQtRoundedRectItemCompareDialog&) = delete;
  QtTestQtRoundedRectItemCompareDialog& operator=(const QtTestQtRoundedRectItemCompareDialog&) = delete;
  ~QtTestQtRoundedRectItemCompareDialog() noexcept;

protected:
  void keyPressEvent(QKeyEvent * event);

private:
  Ui::QtTestQtRoundedRectItemCompareDialog *ui;

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

} //~namespace ribi

#endif // QTTESTQTROUNDEDRECTITEMCOMPAREDIALOG_H

 

 

 

 

 

./ToolTestQtRoundedRectItem/qttestqtroundedrectitemcomparedialog.cpp

 

//---------------------------------------------------------------------------
/*
TestQtRoundedRectItem, tool to test QtRoundedRectItem
Copyright (C) 2012-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/ToolTestQtRoundedRectItem.htm
//---------------------------------------------------------------------------
#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 "qttestqtroundedrectitemcomparedialog.h"

#include <QKeyEvent>

#include "testtimer.h"
#include "trace.h"
#include "ui_qttestqtroundedrectitemcomparedialog.h"
#pragma GCC diagnostic pop

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

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

void ribi::QtTestQtRoundedRectItemCompareDialog::keyPressEvent(QKeyEvent * event)
{
  if (event->key() == Qt::Key_Escape) { close(); return; }
}

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

 

 

 

 

 

./ToolTestQtRoundedRectItem/qttestqtroundedrectitemmenudialog.h

 

//---------------------------------------------------------------------------
/*
TestQtRoundedRectItem, tool to test QtRoundedRectItem
Copyright (C) 2012-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/ToolTestQtRoundedRectItem.htm
//---------------------------------------------------------------------------
#ifndef QTTESTQTROUNDEDRECTITEMMENUDIALOG_H
#define QTTESTQTROUNDEDRECTITEMMENUDIALOG_H

#include "qthideandshowdialog.h"

namespace Ui {
  class QtTestQtRoundedRectItemMenuDialog;
}

namespace ribi {

class QtTestQtRoundedRectItemMenuDialog : public QtHideAndShowDialog
{
  Q_OBJECT

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

protected:

  void keyPressEvent(QKeyEvent * event);

private:
  Ui::QtTestQtRoundedRectItemMenuDialog *ui;

private slots:
  void on_button_about_clicked();
  void on_button_modify_clicked();
  void on_button_quit_clicked();
  void on_button_compare_clicked();

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

} //~namespace ribi

#endif // QTTESTQTROUNDEDRECTITEMMENUDIALOG_H

 

 

 

 

 

./ToolTestQtRoundedRectItem/qttestqtroundedrectitemmenudialog.cpp

 

//---------------------------------------------------------------------------
/*
TestQtRoundedRectItem, tool to test QtRoundedRectItem
Copyright (C) 2012-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/ToolTestQtRoundedRectItem.htm
//---------------------------------------------------------------------------
#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 "qttestqtroundedrectitemmenudialog.h"

#include <QDesktopWidget>
#include <QKeyEvent>

#include "qtkeyboardfriendlygraphicsview.h"
#include "qtroundedrectitem.h"
#include "testqtroundedrectitemmenudialog.h"
#include "qtaboutdialog.h"
#include "qttestqtroundedrectitemcomparedialog.h"
#include "qttestqtroundedrectitemmodifydialog.h"
#include "testtimer.h"
#include "trace.h"
#include "ui_qttestqtroundedrectitemmenudialog.h"

#pragma GCC diagnostic pop

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

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

void ribi::QtTestQtRoundedRectItemMenuDialog::keyPressEvent(QKeyEvent * event)
{
  if (event->key() == Qt::Key_Escape) { close(); return; }
}

void ribi::QtTestQtRoundedRectItemMenuDialog::on_button_about_clicked()
{
  About a = TestQtRoundedRectItemMenuDialog().GetAbout();
  a.AddLibrary("QtHideAndShowDialog version: " + QtHideAndShowDialog::GetVersion());
  a.AddLibrary("QtKeyboardFriendlyGraphicsView version: " + QtKeyboardFriendlyGraphicsView::GetVersion());
  a.AddLibrary("QtRoundedRectItem version: " + QtRoundedRectItem::GetVersion());
  QtAboutDialog d(a);
  d.setWindowIcon(this->windowIcon());
  d.setStyleSheet(this->styleSheet());
  this->ShowChild(&d);
}

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

void ribi::QtTestQtRoundedRectItemMenuDialog::on_button_compare_clicked()
{
  QtTestQtRoundedRectItemCompareDialog d;
  ShowChild(&d);
}

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

void ribi::QtTestQtRoundedRectItemMenuDialog::on_button_modify_clicked()
{
  QtTestQtRoundedRectItemModifyDialog d;
  ShowChild(&d);
}

 

 

 

 

 

./ToolTestQtRoundedRectItem/qttestqtroundedrectitemmodifydialog.h

 

//---------------------------------------------------------------------------
/*
TestQtRoundedRectItem, tool to test QtRoundedRectItem
Copyright (C) 2012-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/ToolTestQtRoundedRectItem.htm
//---------------------------------------------------------------------------
#ifndef QTTESTQTROUNDEDRECTITEMMODIFYDIALOG_H
#define QTTESTQTROUNDEDRECTITEMMODIFYDIALOG_H

#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/shared_ptr.hpp>
#include "qthideandshowdialog.h"
#pragma GCC diagnostic pop

namespace Ui {
class QtTestQtRoundedRectItemModifyDialog;
}

namespace ribi {

struct QtRoundedRectItem;
struct QtRoundedRectItemDialog;

class QtTestQtRoundedRectItemModifyDialog : public QtHideAndShowDialog
{
  Q_OBJECT
    
public:

  explicit QtTestQtRoundedRectItemModifyDialog(QWidget *parent = 0);
  QtTestQtRoundedRectItemModifyDialog(const QtTestQtRoundedRectItemModifyDialog&) = delete;
  QtTestQtRoundedRectItemModifyDialog& operator=(const QtTestQtRoundedRectItemModifyDialog&) = delete;
  ~QtTestQtRoundedRectItemModifyDialog() noexcept;

protected:
  void keyPressEvent(QKeyEvent * event);

private slots:

  void DoSomethingRandom() noexcept;
  void on_button_set_item_clicked();

private:
  Ui::QtTestQtRoundedRectItemModifyDialog *ui;

  ///The dialogs working on a same QtRoundedRectItem
  boost::shared_ptr<QtRoundedRectItemDialog> m_dialog_left;
  boost::shared_ptr<QtRoundedRectItemDialog> m_dialog_right;

  static boost::shared_ptr<QtRoundedRectItem> CreateRandomItem() noexcept;

  void SetItem(const boost::shared_ptr<QtRoundedRectItem>& item) noexcept;

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

} //~namespace ribi

#endif // QTTESTQTROUNDEDRECTITEMMODIFYDIALOG_H

 

 

 

 

 

./ToolTestQtRoundedRectItem/qttestqtroundedrectitemmodifydialog.cpp

 

//---------------------------------------------------------------------------
/*
TestQtRoundedRectItem, tool to test QtRoundedRectItem
Copyright (C) 2012-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/ToolTestQtRoundedRectItem.htm
//---------------------------------------------------------------------------
#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 "qttestqtroundedrectitemmodifydialog.h"

#include <boost/make_shared.hpp>
#include <boost/lambda/lambda.hpp>

#include <QKeyEvent>
#include <QTimer>

#include "qtroundedrectitemdialog.h"
#include "qtroundedrectitem.h"
#include "ribi_random.h"
#include "testtimer.h"
#include "trace.h"
#include "ui_qttestqtroundedrectitemmodifydialog.h"
#pragma GCC diagnostic pop

ribi::QtTestQtRoundedRectItemModifyDialog::QtTestQtRoundedRectItemModifyDialog(QWidget *parent) :
    QtHideAndShowDialog(parent),
    ui(new Ui::QtTestQtRoundedRectItemModifyDialog),
    m_dialog_left(new QtRoundedRectItemDialog),
    m_dialog_right(new QtRoundedRectItemDialog)
{
  #ifndef NDEBUG
  Test();
  #endif
  ui->setupUi(this);

  for (const auto& widget: { ui->widget_left,ui->widget_right })
  {
    if (!widget->layout())
    {
      QVBoxLayout * const layout = new QVBoxLayout;
      widget->setLayout(layout);
    }
  }
  ui->widget_left->layout()->addWidget(m_dialog_left.get());
  ui->widget_right->layout()->addWidget(m_dialog_right.get());

  {
    QTimer * const timer = new QTimer(this);
    QObject::connect(timer,&QTimer::timeout,this,&ribi::QtTestQtRoundedRectItemModifyDialog::DoSomethingRandom);
    timer->setInterval(100);
    timer->start();
  }

  {
    boost::shared_ptr<QtRoundedRectItem> item(new QtRoundedRectItem);
    {
      const QPen pen(
        QBrush(qRgb(0,0,0)),
        2.0,
        Qt::SolidLine
      );
      item->SetContourPen(pen);
    }
    {
      const QPen pen(
        QBrush(qRgb(0,0,0)),
        3.0,
        Qt::DashLine
      );
      item->SetFocusPen(pen);
    }
    item->SetOuterHeight(32.0);
    item->SetCenterPos(0.0,0.0);
    item->SetRadiusX(5.0);
    item->SetRadiusY(6.0);
    item->SetOuterWidth(48.0);
    SetItem(item);
  }

}

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

void ribi::QtTestQtRoundedRectItemModifyDialog::DoSomethingRandom() noexcept
{
  if (!ui->box_change->isChecked()) return;
  m_dialog_left->DoSomethingRandom();
  m_dialog_right->DoSomethingRandom();
}

void ribi::QtTestQtRoundedRectItemModifyDialog::keyPressEvent(QKeyEvent * event)
{
  if (event->key() == Qt::Key_Escape) { close(); return; }
}

boost::shared_ptr<ribi::QtRoundedRectItem> ribi::QtTestQtRoundedRectItemModifyDialog::CreateRandomItem() noexcept
{
  boost::shared_ptr<QtRoundedRectItem> item(new QtRoundedRectItem);
  {
    const QPen pen(
      QBrush(qRgb(std::rand() % 256,std::rand() % 256,std::rand() % 256)),
      1.0 + (static_cast<double>(std::rand() % 100) / 10.0),
      Qt::SolidLine
    );
    item->SetContourPen(pen);
  }
  {
    const QPen pen(
      QBrush(qRgb(std::rand() % 256,std::rand() % 256,std::rand() % 256)),
      1.0 + (static_cast<double>(std::rand() % 100) / 10.0),
      Qt::DashLine
    );
    item->SetFocusPen(pen);
  }
  item->SetInnerHeight(200.0 * Random().GetFraction());
  item->SetCenterPos(
    -50.0 + (100.0 * Random().GetFraction()),
    -50.0 + (100.0 * Random().GetFraction())
  );
  item->SetRadiusX(100.0 * Random().GetFraction());
  item->SetRadiusY(100.0 * Random().GetFraction());
  item->SetInnerWidth(200.0 * Random().GetFraction());
  return item;
}

void ribi::QtTestQtRoundedRectItemModifyDialog::on_button_set_item_clicked()
{
  const auto item = CreateRandomItem();
  assert(item);
  SetItem(item);
}

void ribi::QtTestQtRoundedRectItemModifyDialog::SetItem(const boost::shared_ptr<QtRoundedRectItem>& item) noexcept
{
  m_dialog_left->SetItem(item);
  m_dialog_right->SetItem(item);

  if (!ui->view_left->scene())
  {
    assert(!ui->view_left->scene());
    assert(!ui->view_right->scene());
    QGraphicsScene * const scene = new QGraphicsScene;
    ui->view_left->setScene(scene);
    ui->view_right->setScene(scene);
  }
  assert(ui->view_left->scene());
  assert(ui->view_right->scene());
  assert(ui->view_left->scene() == ui->view_right->scene());
  ui->view_left->scene()->clear();
  ui->view_left->scene()->addItem(item.get());

}

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

 

 

 

 

 

./ToolTestQtRoundedRectItem/qttestqtroundedrectitemwidget.h

 

#ifndef QTTESTQTROUNDEDRECTITEMWIDGET_H
#define QTTESTQTROUNDEDRECTITEMWIDGET_H

#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 "qtkeyboardfriendlygraphicsview.h"
#pragma GCC diagnostic pop

namespace ribi {

///The widget holding the items
///Yes, really use a widget, otherwise the keyPressEvents cannot be forwarded
struct QtTestQtRoundedRectItemWidget : public ribi::QtKeyboardFriendlyGraphicsView
{
  QtTestQtRoundedRectItemWidget(QWidget *parent = 0);
};

} //~namespace ribi

#endif // QTTESTQTROUNDEDRECTITEMWIDGET_H

 

 

 

 

 

./ToolTestQtRoundedRectItem/qttestqtroundedrectitemwidget.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 "qttestqtroundedrectitemwidget.h"

#include <cassert>
#include <cmath>
#include <iostream>

#include <boost/math/constants/constants.hpp>

#include <QGraphicsScene>
#include <QKeyEvent>
#include <QGraphicsSimpleTextItem>

#include "qtroundedrectitem.h"
#include "testtimer.h"
#pragma GCC diagnostic pop

ribi::QtTestQtRoundedRectItemWidget::QtTestQtRoundedRectItemWidget(QWidget *parent)
  : ribi::QtKeyboardFriendlyGraphicsView(parent)
{
  const double pi = boost::math::constants::pi<double>();
  const int n_items = 16;
  for (int i=0; i!=n_items; ++i)
  {
    const double angle = 2.0 * pi * (static_cast<double>(i) / static_cast<double>(n_items));
    {
      const double ray = 200.0;
      const double x =  std::sin(angle) * ray;
      const double y = -std::cos(angle) * ray;
      QtRoundedRectItem * const item = new QtRoundedRectItem;
      assert(item);
      item->SetCenterPos(x,y);
      item->SetInnerWidth(64.0);
      item->SetInnerHeight(32.0);
      assert(scene());
      scene()->addItem(item);
    }
    {
      const double ray = 120.0;
      const double x =  std::sin(angle) * ray;
      const double y = -std::cos(angle) * ray;
      QGraphicsRectItem * const item = new QGraphicsRectItem;
      assert(item);
      item->setFlags(
          QGraphicsItem::ItemIsFocusable
        | QGraphicsItem::ItemIsMovable
        | QGraphicsItem::ItemIsSelectable
      );
      item->setPos(x,y);
      item->setRect(-16.0,-16.0,32.0,32.0);
      assert(scene());
      scene()->addItem(item);
    }
  }
  //Add texts
  {
    const std::vector<std::string> v
      =
      {
        "Goal: compare my custom class to the Qt class",
        "Outer ring: my custom QtRoundedRectItem",
        "Inner ring: Qt its QGraphicsRectItem (note that these do not indicate being selected)",
        "Space: set focus to random item",
        "Arrow keys: move focus",
        "Shift + arrow keys: move item"
        //"F2: edit item"
      };
    const int sz = boost::numeric_cast<int>(v.size());
    for (int i=0; i!=sz; ++i)
    {
      QGraphicsSimpleTextItem * const item = new QGraphicsSimpleTextItem(v[i].c_str());
      const double w = item->boundingRect().width();
      const double h = item->boundingRect().height();
      const double x = -300.0;
      const double y = -300.0 + (static_cast<double>(i - (sz/2)) * 20.0);
      item->setPos((-0.5 * w) + x,(-0.5 * h) + y);
      assert(!item->scene());
      scene()->addItem(item);
    }
  }

}

 

 

 

 

 

./ToolTestQtRoundedRectItem/testqtroundedrectitemmenudialog.h

 

#ifndef TESTQTROUNDEDRECTITEMWIDGETMENUDIALOG_H
#define TESTQTROUNDEDRECTITEMWIDGETMENUDIALOG_H

#include "menudialog.h"

namespace ribi {

struct TestQtRoundedRectItemMenuDialog 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 // TESTQTROUNDEDRECTITEMWIDGETMENUDIALOG_H

 

 

 

 

 

./ToolTestQtRoundedRectItem/testqtroundedrectitemmenudialog.cpp

 

#include "testqtroundedrectitemmenudialog.h"

#include <cassert>
#include <iostream>

#include "fileio.h"
#include "geometry.h"
#include "plane.h"
#include "ribi_regex.h"
#include "richelbilderbeekprogram.h"
#include "testtimer.h"
#include "trace.h"

int ribi::TestQtRoundedRectItemMenuDialog::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::TestQtRoundedRectItemMenuDialog::GetAbout() const noexcept
{
  About a(
    "Richel Bilderbeek",
    "TestQtRoundedRectItem",
    "tests QtRoundedRectItemt",
    "the 14th of June 2014",
    "2012-2015",
    "http://www.richelbilderbeek.nl/ToolTestQtRoundedRectItem.htm",
    GetVersion(),
    GetVersionHistory());
  a.AddLibrary("FileIo version: " + fileio::FileIo().GetVersion());
  a.AddLibrary("Geometry version: " + Geometry().GetVersion());
  a.AddLibrary("Plane version: " + Plane::GetVersion());
  a.AddLibrary("ribi::Regex version: " + Regex::GetVersion());
  a.AddLibrary("Trace version: " + Trace::GetVersion());
  return a;
}

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

    },
    {

    }
  );
}

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

std::string ribi::TestQtRoundedRectItemMenuDialog::GetVersion() const noexcept
{
  return "1.6";
}

std::vector<std::string> ribi::TestQtRoundedRectItemMenuDialog::GetVersionHistory() const noexcept
{
  return {
    "2012-12-21: version 1.0: initial version",
    "2012-05-20: version 1.1: added menu",
    "2013-11-05: version 1.2: conformized for ProjectRichelBilderbeekConsole",
    "2014-06-10: version 1.3: use QtKeyboardFriendlyGraphicView in desktop version",
    "2014-06-14: version 1.4: added 'Modify' dialog to desktop version",
    "2016-06-14: version 1.5: fixed issue #219",
    "2016-06-16: version 1.6: added QtRoundedEditRectItemDialog"
  };
}

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

 

 

 

 

 

./ToolTestQtRoundedRectItem/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 ToolTestQtRoundedRectItem.pro

echo "2/2: making makefile"

make

echo "Done"

 

 

 

 

 

./ToolTestQtRoundedRectItem/zip.sh

 

#!/bin/sh
# Created from file '../../Tools/ToolTestQtRoundedRectItem/ToolTestQtRoundedRectItem.pro'

echo "Creating of all folders"

mkdir Projects
mkdir Projects/Tools
mkdir Projects/Classes
mkdir Projects/Classes/CppAbout
mkdir Projects/Classes/CppTrace
mkdir Projects/Classes/CppQtAboutDialog
mkdir Projects/Classes/CppQtRoundedRectItem
mkdir Projects/Classes/CppQtHideAndShowDialog
mkdir Projects/Tools/ToolTestQtRoundedRectItem
mkdir Projects/Classes/CppQtKeyboardFriendlyGraphicsView

echo "Copying files"

cp ../../Classes/CppAbout/about.h Projects/Classes/CppAbout/about.h
cp ../../Classes/CppTrace/trace.h Projects/Classes/CppTrace/trace.h
cp ../../Classes/CppAbout/about.cpp Projects/Classes/CppAbout/about.cpp
cp ../../Classes/CppAbout/Licence.txt Projects/Classes/CppAbout/Licence.txt
cp ../../Classes/CppTrace/Licence.txt Projects/Classes/CppTrace/Licence.txt
cp ../../Classes/CppQtAboutDialog/Licence.txt Projects/Classes/CppQtAboutDialog/Licence.txt
cp ../../Tools/ToolTestQtRoundedRectItem/R.png Projects/Tools/ToolTestQtRoundedRectItem/R.png
cp ../../Tools/ToolTestQtRoundedRectItem/zip.sh Projects/Tools/ToolTestQtRoundedRectItem/zip.sh
cp ../../Classes/CppQtAboutDialog/qtaboutdialog.h Projects/Classes/CppQtAboutDialog/qtaboutdialog.h
cp ../../Classes/CppQtRoundedRectItem/Licence.txt Projects/Classes/CppQtRoundedRectItem/Licence.txt
cp ../../Classes/CppQtAboutDialog/qtaboutdialog.ui Projects/Classes/CppQtAboutDialog/qtaboutdialog.ui
cp ../../Classes/CppQtAboutDialog/qtaboutdialog.cpp Projects/Classes/CppQtAboutDialog/qtaboutdialog.cpp
cp ../../Classes/CppQtHideAndShowDialog/Licence.txt Projects/Classes/CppQtHideAndShowDialog/Licence.txt
cp ../../Tools/ToolTestQtRoundedRectItem/qtmain.cpp Projects/Tools/ToolTestQtRoundedRectItem/qtmain.cpp
cp ../../Tools/ToolTestQtRoundedRectItem/Licence.txt Projects/Tools/ToolTestQtRoundedRectItem/Licence.txt
cp ../../Classes/CppQtRoundedRectItem/qtroundedrectitem.h Projects/Classes/CppQtRoundedRectItem/qtroundedrectitem.h
cp ../../Classes/CppQtRoundedRectItem/qtroundedrectitem.cpp Projects/Classes/CppQtRoundedRectItem/qtroundedrectitem.cpp
cp ../../Classes/CppQtHideAndShowDialog/qthideandshowdialog.h Projects/Classes/CppQtHideAndShowDialog/qthideandshowdialog.h
cp ../../Classes/CppQtKeyboardFriendlyGraphicsView/Licence.txt Projects/Classes/CppQtKeyboardFriendlyGraphicsView/Licence.txt
cp ../../Classes/CppQtHideAndShowDialog/qthideandshowdialog.cpp Projects/Classes/CppQtHideAndShowDialog/qthideandshowdialog.cpp
cp ../../Tools/ToolTestQtRoundedRectItem/ToolTestQtRoundedRectItem.pro Projects/Tools/ToolTestQtRoundedRectItem/ToolTestQtRoundedRectItem.pro
cp ../../Tools/ToolTestQtRoundedRectItem/ToolTestQtRoundedRectItem.qrc Projects/Tools/ToolTestQtRoundedRectItem/ToolTestQtRoundedRectItem.qrc
cp ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemwidget.h Projects/Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemwidget.h
cp ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemwidget.cpp Projects/Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemwidget.cpp
cp ../../Tools/ToolTestQtRoundedRectItem/testqtroundedrectitemmenudialog.h Projects/Tools/ToolTestQtRoundedRectItem/testqtroundedrectitemmenudialog.h
cp ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmaindialog.h Projects/Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmaindialog.h
cp ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmenudialog.h Projects/Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmenudialog.h
cp ../../Tools/ToolTestQtRoundedRectItem/testqtroundedrectitemmenudialog.cpp Projects/Tools/ToolTestQtRoundedRectItem/testqtroundedrectitemmenudialog.cpp
cp ../../Tools/ToolTestQtRoundedRectItem/ToolTestQtRoundedRectItemWelcome.png Projects/Tools/ToolTestQtRoundedRectItem/ToolTestQtRoundedRectItemWelcome.png
cp ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmaindialog.ui Projects/Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmaindialog.ui
cp ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmenudialog.ui Projects/Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmenudialog.ui
cp ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmaindialog.cpp Projects/Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmaindialog.cpp
cp ../../Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmenudialog.cpp Projects/Tools/ToolTestQtRoundedRectItem/qttestqtroundedrectitemmenudialog.cpp
cp ../../Classes/CppQtKeyboardFriendlyGraphicsView/qtkeyboardfriendlygraphicsview.h Projects/Classes/CppQtKeyboardFriendlyGraphicsView/qtkeyboardfriendlygraphicsview.h
cp ../../Classes/CppQtKeyboardFriendlyGraphicsView/qtkeyboardfriendlygraphicsview.cpp Projects/Classes/CppQtKeyboardFriendlyGraphicsView/qtkeyboardfriendlygraphicsview.cpp

FILENAME="../../Tools/ToolTestQtRoundedRectItemSource"
ZIP_FILENAME=$FILENAME".zip"

echo "Compressing files"

zip -r $FILENAME Projects

echo "Cleaning up"

echo "Emptying subfolders"

rm Projects/Classes/CppQtKeyboardFriendlyGraphicsView/*.*
rm Projects/Tools/ToolTestQtRoundedRectItem/*.*
rm Projects/Classes/CppQtHideAndShowDialog/*.*
rm Projects/Classes/CppQtRoundedRectItem/*.*
rm Projects/Classes/CppQtAboutDialog/*.*
rm Projects/Classes/CppTrace/*.*
rm Projects/Classes/CppAbout/*.*
rm Projects/Classes/*.*
rm Projects/Tools/*.*
rm Projects/*.*
rmdir Projects/Classes/CppQtKeyboardFriendlyGraphicsView
rmdir Projects/Tools/ToolTestQtRoundedRectItem
rmdir Projects/Classes/CppQtHideAndShowDialog
rmdir Projects/Classes/CppQtRoundedRectItem
rmdir Projects/Classes/CppQtAboutDialog
rmdir Projects/Classes/CppTrace
rmdir Projects/Classes/CppAbout
rmdir Projects/Classes
rmdir Projects/Tools
rmdir Projects

echo "Done"

# QtCreatorProFileZipScript, version 1.0
# Copyright (C) 2013 Richel Bilderbeek
# Programmed on the 19th of May 2013
# by Richel Bilderbeek
#
# QtCreatorProFileZipScript can be downloaded from http://www.richelbilderbeek.nl/CppQtCreatorProFileZipScript.htm
# Licenced under GPL 3.0

 

 

 

 

 

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