Engauge Digitizer
2
Main Page
Classes
Files
File List
File Members
Tutorial
TutorialDlg.cpp
1
#include "EngaugeAssert.h"
2
#include "Logger.h"
3
#include "MainWindow.h"
4
#include <QGraphicsRectItem>
5
#include <QGraphicsScene>
6
#include <QGraphicsView>
7
#include <QVBoxLayout>
8
#include "TutorialDlg.h"
9
#include "TutorialStateContext.h"
10
11
const
int
SCENE_WIDTH = 550;
12
const
int
SCENE_HEIGHT = 450;
13
14
TutorialDlg::TutorialDlg
(
MainWindow
*mainWindow) :
15
QDialog (mainWindow)
16
{
17
setWindowTitle (
"Engauge Digitizer Tutorial"
);
18
19
// Dialog size is determined by scene size
20
QVBoxLayout *layout =
new
QVBoxLayout;
21
layout->setSizeConstraint (QLayout::SetFixedSize);
22
setLayout (layout);
23
24
createSceneAndView();
25
createContext();
26
}
27
28
QSize
TutorialDlg::backgroundSize
()
const
29
{
30
return
QSize (SCENE_WIDTH,
31
SCENE_HEIGHT);
32
}
33
void
TutorialDlg::createContext ()
34
{
35
m_context =
new
TutorialStateContext
(*
this
);
36
}
37
38
void
TutorialDlg::createSceneAndView ()
39
{
40
LOG4CPP_INFO_S ((*mainCat)) <<
"TutorialDlg::createSceneAndView"
;
41
42
m_scene =
new
QGraphicsScene (
this
);
43
44
m_view =
new
QGraphicsView (m_scene,
this
);
45
m_view->setMouseTracking (
true
);
46
layout ()->addWidget(m_view);
47
48
// Spacer is used to ensure view is the desired size. Directly setting the size of the view
49
// is ineffective since the view then get resized to the smallest rectangle fitting the added items
50
QGraphicsRectItem *spacer =
new
QGraphicsRectItem (0,
51
0,
52
backgroundSize
().width (),
53
backgroundSize
().height ());
54
spacer->setBrush (QBrush (Qt::NoBrush));
55
spacer->setPen (QPen (Qt::NoPen));
56
spacer->setZValue(-1);
// Put behind everything else at the default z of zero
57
m_scene->addItem (spacer);
58
}
59
60
QGraphicsScene &
TutorialDlg::scene
()
61
{
62
ENGAUGE_CHECK_PTR (m_scene);
63
64
return
*m_scene;
65
}
66
67
QGraphicsView &
TutorialDlg::view
()
68
{
69
ENGAUGE_CHECK_PTR (m_view);
70
71
return
*m_view;
72
}
TutorialDlg::TutorialDlg
TutorialDlg(MainWindow *mainWindow)
Single constructor.
Definition:
TutorialDlg.cpp:14
TutorialDlg::scene
QGraphicsScene & scene()
Single scene the covers the entire tutorial dialog.
Definition:
TutorialDlg.cpp:60
TutorialDlg::backgroundSize
QSize backgroundSize() const
Make geometry available for layout.
Definition:
TutorialDlg.cpp:28
TutorialStateContext
Context class for tutorial state machine.
Definition:
TutorialStateContext.h:14
TutorialDlg::view
QGraphicsView & view()
Single view that displays the single scene.
Definition:
TutorialDlg.cpp:67
MainWindow
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition:
MainWindow.h:60
Generated on Sun Nov 8 2015 13:15:08 for Engauge Digitizer by
1.8.9.1