Engauge Digitizer
2
Main Page
Classes
Files
File List
All
Classes
Functions
Variables
Typedefs
Enumerations
Friends
Pages
Tutorial
TutorialDlg.cpp
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"
15
#include "TutorialStateContext.h"
16
17
const
int
SCENE_WIDTH = 550;
18
const
int
SCENE_HEIGHT = 450;
19
20
TutorialDlg::TutorialDlg
(
MainWindow
*mainWindow) :
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
29
QVBoxLayout *layout =
new
QVBoxLayout;
30
layout->setSizeConstraint (QLayout::SetFixedSize);
31
setLayout (layout);
32
33
createSceneAndView();
34
createContext();
35
}
36
37
TutorialDlg::~TutorialDlg ()
38
{
39
delete
m_view;
40
delete
m_scene;
41
delete
m_context;
42
}
43
44
QSize
TutorialDlg::backgroundSize
()
const
45
{
46
return
QSize (SCENE_WIDTH,
47
SCENE_HEIGHT);
48
}
49
void
TutorialDlg::createContext ()
50
{
51
m_context =
new
TutorialStateContext
(*
this
);
52
}
53
54
void
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 (),
69
backgroundSize
().height ());
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
76
QGraphicsScene &
TutorialDlg::scene
()
77
{
78
ENGAUGE_CHECK_PTR (m_scene);
79
80
return
*m_scene;
81
}
82
83
QGraphicsView &
TutorialDlg::view
()
84
{
85
ENGAUGE_CHECK_PTR (m_view);
86
87
return
*m_view;
88
}
TutorialDlg::TutorialDlg
TutorialDlg(MainWindow *mainWindow)
Single constructor.
Definition:
TutorialDlg.cpp:20
TutorialDlg::scene
QGraphicsScene & scene()
Single scene the covers the entire tutorial dialog.
Definition:
TutorialDlg.cpp:76
TutorialDlg::backgroundSize
QSize backgroundSize() const
Make geometry available for layout.
Definition:
TutorialDlg.cpp:44
TutorialStateContext
Context class for tutorial state machine.
Definition:
TutorialStateContext.h:20
TutorialDlg::view
QGraphicsView & view()
Single view that displays the single scene.
Definition:
TutorialDlg.cpp:83
MainWindow
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition:
MainWindow.h:91
Generated on Sat Jul 20 2019 17:42:49 for Engauge Digitizer by
1.8.5