Engauge Digitizer 2
Loading...
Searching...
No Matches
TutorialDlg.cpp
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5 ******************************************************************************************************/
6
7#include "EngaugeAssert.h"
8#include "Logger.h"
9#include "MainWindow.h"
10#include <QGraphicsRectItem>
11#include <QGraphicsScene>
12#include <QGraphicsView>
13#include <QVBoxLayout>
14#include "TutorialDlg.h"
16
17const int SCENE_WIDTH = 580;
18const int SCENE_HEIGHT = 480;
19
21 QDialog (mainWindow),
22 m_context (nullptr),
23 m_scene (nullptr),
24 m_view (nullptr)
25{
26 setWindowTitle ("Engauge Digitizer Tutorial");
27
28 // Dialog size is determined by scene size
30 layout->setSizeConstraint (QLayout::SetMinimumSize);
31 setLayout (layout);
32
33 createSceneAndView();
34 createContext();
35}
36
38{
39 delete m_view;
40 delete m_scene;
41 delete m_context;
42}
43
49void TutorialDlg::createContext ()
50{
51 m_context = new TutorialStateContext(*this);
52}
53
54void TutorialDlg::createSceneAndView ()
55{
56 LOG4CPP_INFO_S ((*mainCat)) << "TutorialDlg::createSceneAndView";
57
58 m_scene = new QGraphicsScene (this);
59
60 m_view = new QGraphicsView (m_scene, this);
61 m_view->setMouseTracking (true);
62 layout ()->addWidget(m_view);
63
64 // Spacer is used to ensure view is the desired size. Directly setting the size of the view
65 // is ineffective since the view then get resized to the smallest rectangle fitting the added items
66 QGraphicsRectItem *spacer = new QGraphicsRectItem (0,
67 0,
68 backgroundSize().width (),
70 spacer->setBrush (QBrush (Qt::NoBrush));
71 spacer->setPen (QPen (Qt::NoPen));
72 spacer->setZValue(-1); // Put behind everything else at the default z of zero
73 m_scene->addItem (spacer);
74}
75
76QGraphicsScene &TutorialDlg::scene ()
77{
78 ENGAUGE_CHECK_PTR (m_scene);
79
80 return *m_scene;
81}
82
83QGraphicsView &TutorialDlg::view ()
84{
85 ENGAUGE_CHECK_PTR (m_view);
86
87 return *m_view;
88}
const int INNER_RADIUS_MIN
#define ENGAUGE_CHECK_PTR(ptr)
#endif
log4cpp::Category * mainCat
Definition Logger.cpp:14
const int SCENE_HEIGHT
const int SCENE_WIDTH
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition MainWindow.h:92
QGraphicsView & view()
Single view that displays the single scene.
TutorialDlg(MainWindow *mainWindow)
Single constructor.
QGraphicsScene & scene()
Single scene the covers the entire tutorial dialog.
QSize backgroundSize() const
Make geometry available for layout.
Context class for tutorial state machine.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18