Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
einsteinathome
pulsatingscience
Commits
01f66fe5
Commit
01f66fe5
authored
Sep 12, 2017
by
Oliver Bock
Browse files
Slightly refactored drawCurve (into plot) to facilitate next steps
parent
99313a66
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/pulsatingscience.cpp
View file @
01f66fe5
...
...
@@ -59,7 +59,7 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
// establish object communications
connect
(
ui
.
pulsarGlWidget
,
SIGNAL
(
pulseProfileUpdated
(
const
QVector
<
double
>&
)),
ui
.
pulseScopeWidget
,
SLOT
(
drawCurve
(
const
QVector
<
double
>&
)),
Qt
::
DirectConnection
);
ui
.
pulseScopeWidget
,
SLOT
(
plot
(
const
QVector
<
double
>&
)),
Qt
::
DirectConnection
);
connect
(
m_hiddenShortcut
,
SIGNAL
(
activated
()),
this
,
SLOT
(
toggleHiddenDemoMode
()));
...
...
src/pulsescopewidget.cpp
View file @
01f66fe5
...
...
@@ -59,7 +59,7 @@ PulseScopeWidget::PulseScopeWidget(QWidget *parent) : QGraphicsView(parent),
setScene
(
&
m_scene
);
m_data
.
fill
(
0.0
,
qRound
(
m_scopeSizeH
));
drawCurve
(
m_
data
);
drawCurve
(
m_
path
,
m_data
,
"black"
);
}
PulseScopeWidget
::~
PulseScopeWidget
()
...
...
@@ -74,18 +74,22 @@ void PulseScopeWidget::resizeEvent(QResizeEvent *event)
fitInView
(
m_scene
.
itemsBoundingRect
(),
Qt
::
IgnoreAspectRatio
);
}
void
PulseScopeWidget
::
drawCurve
(
const
QVector
<
double
>&
vector
)
void
PulseScopeWidget
::
plot
(
const
QVector
<
double
>&
vector
)
{
m_data
=
vector
;
drawCurve
(
m_path
,
vector
,
"yellow"
);
}
QPainterPath
pulsePath
(
QPointF
(
0.0
,
m_scopeSizeV
-
m_data
.
at
(
0
)
-
1.0
));
void
PulseScopeWidget
::
drawCurve
(
QGraphicsPathItem
*
path
,
const
QVector
<
double
>&
vector
,
QString
color
)
{
QPainterPath
pulsePath
(
QPointF
(
0.0
,
m_scopeSizeV
-
vector
.
at
(
0
)
-
1.0
));
for
(
int
i
=
1
;
i
<
m_scopeSizeH
;
++
i
)
{
pulsePath
.
lineTo
(
i
,
m_scopeSizeV
-
m_data
.
at
(
i
)
-
1.0
);
pulsePath
.
lineTo
(
i
,
m_scopeSizeV
-
vector
.
at
(
i
)
-
1.0
);
}
if
(
m_
path
==
NULL
)
{
m_
path
=
m_scene
.
addPath
(
pulsePath
,
QPen
(
Q
t
::
yellow
));
if
(
path
==
NULL
)
{
path
=
m_scene
.
addPath
(
pulsePath
,
QPen
(
Q
Color
(
color
)
));
}
else
{
m_path
->
setPath
(
pulsePath
);
path
->
setPen
(
QPen
(
QColor
(
color
)));
path
->
setPath
(
pulsePath
);
}
}
src/pulsescopewidget.h
View file @
01f66fe5
...
...
@@ -42,9 +42,11 @@ public:
void
resizeEvent
(
QResizeEvent
*
event
);
public
slots
:
void
drawCurve
(
const
QVector
<
double
>&
vector
);
void
plot
(
const
QVector
<
double
>&
vector
);
private:
void
drawCurve
(
QGraphicsPathItem
*
path
,
const
QVector
<
double
>&
vector
,
QString
color
);
QGraphicsScene
m_scene
;
QVector
<
double
>
m_data
;
QGraphicsPathItem
*
m_path
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment