Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cuteLib-hsrt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Glaser
cuteLib-hsrt
Commits
949b618d
Commit
949b618d
authored
3 months ago
by
tobiglaser
Browse files
Options
Downloads
Patches
Plain Diff
added Reset Button to Chart Menu + some refactoring
parent
099c2e7f
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/chartMenu.cpp
+78
-47
78 additions, 47 deletions
src/chartMenu.cpp
src/chartMenu.h
+7
-4
7 additions, 4 deletions
src/chartMenu.h
src/control.cpp
+1
-0
1 addition, 0 deletions
src/control.cpp
with
86 additions
and
51 deletions
src/chartMenu.cpp
+
78
−
47
View file @
949b618d
...
...
@@ -2,61 +2,64 @@
#include
"cute.h"
#include
<QAction.h>
#include
<QCheckBox>
#include
<QDialog>
#include
<QDialogButtonBox>
#include
<QLabel>
#include
<QLogValueAxis>
#include
<QVBoxLayout>
#include
<QValueAxis>
#include
<qaction.h>
#include
<string>
ChartMenu
::
ChartMenu
(
std
::
vector
<
QWidget
*>&
graphingWidgets
,
QWidget
*
parent
)
:
QMenu
(
parent
)
{
cv
=
graphingWidgets
;
this
->
graphingWidgets
=
graphingWidgets
;
for
(
size_t
i
=
0
;
i
<
cv
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
graphingWidgets
.
size
();
++
i
)
{
QString
name
=
"Plot "
;
name
+=
std
::
to_string
(
i
).
c_str
();
QAction
*
checkboxAction
=
new
QAction
(
name
,
this
);
vis
.
push_back
(
checkboxAction
);
QAction
*
menuCheck
=
new
QAction
(
name
,
this
);
titles
.
push_back
(
name
);
visMenu
.
push_back
(
menuCheck
);
menuCheck
->
setCheckable
(
true
);
menuCheck
->
setChecked
(
!
cv
[
i
]
->
isHidden
());
checkboxAction
->
setCheckable
(
true
);
// Make it checkable
checkboxAction
->
setChecked
(
!
cv
[
i
]
->
isHidden
());
QtCharts
::
QChartView
*
chartView
=
dynamic_cast
<
QtCharts
::
QChartView
*>
(
cv
[
i
]);
if
(
!
chartView
)
{
addAction
(
checkboxAction
);
connect
(
checkboxAction
,
&
QAction
::
triggered
,
this
,
&
ChartMenu
::
onOptionSelected
);
}
else
{
QString
name
=
"Plot "
;
name
+=
std
::
to_string
(
i
).
c_str
();
addAction
(
menuCheck
);
QMenu
*
scaleMenu
=
new
QMenu
(
name
);
menuCheck
->
setMenu
(
scaleMenu
);
QAction
*
menuAction
=
new
QAction
(
name
,
this
);
menuActions
.
push_back
(
menuAction
);
menuAction
->
setCheckable
(
true
);
menuAction
->
setChecked
(
!
graphingWidgets
[
i
]
->
isHidden
());
addAction
(
menuAction
);
scaleMenu
->
addAction
(
checkboxAction
);
connect
(
checkboxAction
,
&
QAction
::
triggered
,
this
,
&
ChartMenu
::
onOptionSelected
);
scaleMenu
->
addSeparator
();
QMenu
*
menu
=
new
QMenu
(
name
);
menuAction
->
setMenu
(
menu
);
QAction
*
visibilityAction
=
new
QAction
(
name
,
this
);
visibilityAction
->
setCheckable
(
true
);
// Make it checkable
visibilityAction
->
setChecked
(
!
graphingWidgets
[
i
]
->
isHidden
());
visibiliyActions
.
push_back
(
visibilityAction
);
menu
->
addAction
(
visibilityAction
);
connect
(
visibilityAction
,
&
QAction
::
triggered
,
this
,
&
ChartMenu
::
onVisibility
);
QAction
*
resetAction
=
new
QAction
(
"Reset"
,
this
);
menu
->
addAction
(
resetAction
);
resetActions
.
push_back
(
resetAction
);
connect
(
resetAction
,
&
QAction
::
triggered
,
this
,
&
ChartMenu
::
onReset
);
QtCharts
::
QChartView
*
chartView
=
dynamic_cast
<
QtCharts
::
QChartView
*>
(
graphingWidgets
[
i
]);
if
(
chartView
)
{
menu
->
addSeparator
();
QAction
*
xlinAction
=
new
QAction
(
"X - linear"
);
xlinAction
->
setCheckable
(
true
);
scaleM
enu
->
addAction
(
xlinAction
);
m
enu
->
addAction
(
xlinAction
);
QAction
*
xlogAction
=
new
QAction
(
"X - logarithmic"
);
xlogAction
->
setCheckable
(
true
);
scaleM
enu
->
addAction
(
xlogAction
);
scaleM
enu
->
addSeparator
();
m
enu
->
addAction
(
xlogAction
);
m
enu
->
addSeparator
();
QAction
*
ylinAction
=
new
QAction
(
"Y - linear"
);
ylinAction
->
setCheckable
(
true
);
scaleM
enu
->
addAction
(
ylinAction
);
m
enu
->
addAction
(
ylinAction
);
QAction
*
ylogAction
=
new
QAction
(
"Y - logarithmic"
);
ylogAction
->
setCheckable
(
true
);
scaleM
enu
->
addAction
(
ylogAction
);
m
enu
->
addAction
(
ylogAction
);
scaleBundles
.
push_back
({
xlinAction
,
xlogAction
,
ylinAction
,
ylogAction
,
chartView
});
connect
(
xlinAction
,
&
QAction
::
triggered
,
this
,
&
ChartMenu
::
onScale
);
connect
(
xlogAction
,
&
QAction
::
triggered
,
this
,
&
ChartMenu
::
onScale
);
...
...
@@ -71,12 +74,12 @@ ChartMenu::ChartMenu(std::vector<QWidget*>& graphingWidgets, QWidget* parent) :
void
ChartMenu
::
onShow
()
{
for
(
size_t
i
=
0
;
i
<
cv
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
graphingWidgets
.
size
();
++
i
)
{
vis
[
i
]
->
setChecked
(
!
cv
[
i
]
->
isHidden
());
vis
[
i
]
->
setText
(
titles
[
i
]
);
visMenu
[
i
]
->
setChecked
(
!
cv
[
i
]
->
isHidden
());
visMenu
[
i
]
->
setText
(
titles
[
i
]);
vis
ibiliyActions
[
i
]
->
setChecked
(
!
graphingWidgets
[
i
]
->
isHidden
());
vis
ibiliyActions
[
i
]
->
setText
(
graphingWidgets
[
i
]
->
isHidden
()
?
"show"
:
"hide"
);
menuActions
[
i
]
->
setChecked
(
!
graphingWidgets
[
i
]
->
isHidden
());
menuActions
[
i
]
->
setText
(
titles
[
i
]);
}
for
(
auto
&&
sB
:
scaleBundles
)
...
...
@@ -116,16 +119,44 @@ void ChartMenu::onShow()
}
}
void
ChartMenu
::
onOptionSelected
()
void
ChartMenu
::
onVisibility
()
{
QAction
*
senderAction
=
qobject_cast
<
QAction
*>
(
sender
());
if
(
senderAction
)
{
for
(
size_t
i
=
0
;
i
<
visibiliyActions
.
size
();
++
i
)
{
if
(
senderAction
==
visibiliyActions
[
i
])
{
graphingWidgets
[
i
]
->
setHidden
(
!
senderAction
->
isChecked
());
}
}
}
}
void
ChartMenu
::
onReset
()
{
QAction
*
senderAction
=
qobject_cast
<
QAction
*>
(
sender
());
if
(
senderAction
)
{
for
(
size_t
i
=
0
;
i
<
vi
s
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
resetAction
s
.
size
();
++
i
)
{
if
(
senderAction
==
vi
s
[
i
])
if
(
senderAction
==
resetAction
s
[
i
])
{
cv
[
i
]
->
setHidden
(
!
senderAction
->
isChecked
());
QDialog
dialog
;
dialog
.
setWindowTitle
(
"Confirm Reset"
);
dialog
.
setWindowFlags
(
Qt
::
Dialog
|
Qt
::
WindowTitleHint
|
Qt
::
WindowCloseButtonHint
);
QVBoxLayout
layout
(
&
dialog
);
QLabel
label
(
"Reset "
+
titles
[
i
]
+
'?'
);
layout
.
addWidget
(
&
label
);
QDialogButtonBox
buttonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
);
layout
.
addWidget
(
&
buttonBox
);
QObject
::
connect
(
&
buttonBox
,
&
QDialogButtonBox
::
accepted
,
&
dialog
,
&
QDialog
::
accept
);
QObject
::
connect
(
&
buttonBox
,
&
QDialogButtonBox
::
rejected
,
&
dialog
,
&
QDialog
::
reject
);
// modal execution
int
result
=
dialog
.
exec
();
if
(
result
==
QDialog
::
Accepted
)
emit
s_resetPlot
(
i
);
}
}
}
...
...
@@ -182,9 +213,9 @@ void ChartMenu::onScale()
}
}
int
plotIndex
=
-
1
;
for
(
size_t
i
=
0
;
i
<
cv
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
graphingWidgets
.
size
();
++
i
)
{
if
(
cv
[
i
]
==
bundle
.
chartView
)
if
(
graphingWidgets
[
i
]
==
bundle
.
chartView
)
plotIndex
=
i
;
}
int
newX
=
oldXlin
?
cute
::
Scale
::
linear
:
cute
::
Scale
::
logarithmic
;
...
...
This diff is collapsed.
Click to expand it.
src/chartMenu.h
+
7
−
4
View file @
949b618d
...
...
@@ -21,9 +21,10 @@ private:
};
private
:
std
::
vector
<
QWidget
*>
cv
;
std
::
vector
<
QAction
*>
vis
;
std
::
vector
<
QAction
*>
visMenu
;
std
::
vector
<
QWidget
*>
graphingWidgets
;
std
::
vector
<
QAction
*>
visibiliyActions
;
std
::
vector
<
QAction
*>
resetActions
;
std
::
vector
<
QAction
*>
menuActions
;
int
chartTheme
;
std
::
vector
<
scaleBundle
>
scaleBundles
;
...
...
@@ -36,14 +37,16 @@ public:
private
slots
:
void
onShow
();
void
onScale
();
void
onReset
();
public
slots
:
void
on
OptionSelected
();
void
on
Visibility
();
void
chartThemeChanged
(
int
themeNumber
);
void
titleChanged
(
int
plot
,
const
QString
&
title
);
signals
:
void
s_setPlotScale
(
int
plot
,
int
x
,
int
y
);
void
s_resetPlot
(
int
plot
);
};
...
...
This diff is collapsed.
Click to expand it.
src/control.cpp
+
1
−
0
View file @
949b618d
...
...
@@ -49,6 +49,7 @@ void Control::makeConnections()
connect
(
w
->
configPanel
,
&
ConfigPanel
::
lockButtonClicked
,
this
,
&
Control
::
onLockButton
);
connect
(
w
,
&
MainWindow
::
saveProblem
,
this
,
&
Control
::
saveProblem
);
connect
(
w
->
cm
,
&
ChartMenu
::
s_setPlotScale
,
this
,
&
Control
::
setPlotScale
);
connect
(
w
->
cm
,
&
ChartMenu
::
s_resetPlot
,
this
,
&
Control
::
resetPlot
);
connect
(
cc
,
&
CuteControl
::
s_verbosityChanged
,
w
,
&
MainWindow
::
changeVerbosity
);
connect
(
w
->
configPanel
->
verbosityBox
,
QOverload
<
int
>::
of
(
&
QComboBox
::
currentIndexChanged
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment