Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
b549ec60
Commit
b549ec60
authored
7 years ago
by
Yurov, Dmitry
Browse files
Options
Downloads
Patches
Plain Diff
Enable specular plot canvas in specular data canvas
parent
7a039349
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/coregui/Views/SpecularDataWidgets/SpecularDataCanvas.cpp
+19
-56
19 additions, 56 deletions
GUI/coregui/Views/SpecularDataWidgets/SpecularDataCanvas.cpp
GUI/coregui/Views/SpecularDataWidgets/SpecularDataCanvas.h
+4
-6
4 additions, 6 deletions
GUI/coregui/Views/SpecularDataWidgets/SpecularDataCanvas.h
with
23 additions
and
62 deletions
GUI/coregui/Views/SpecularDataWidgets/SpecularDataCanvas.cpp
+
19
−
56
View file @
b549ec60
...
...
@@ -18,46 +18,34 @@
#include
"SavePlotAssistant.h"
#include
"SpecularDataCanvas.h"
#include
"SpecularDataItem.h"
#include
"SpecularPlotCanvas.h"
#include
"plot_constants.h"
SpecularDataCanvas
::
SpecularDataCanvas
(
QWidget
*
parent
)
:
SessionItemWidget
(
parent
)
,
m_
customPlot
(
new
QCustomPlot
)
,
m_reset
V
iew
A
ction
(
nullptr
)
,
m_save
P
lot
A
ction
(
nullptr
)
,
m_
plot_canvas
(
new
SpecularPlotCanvas
)
,
m_reset
_v
iew
_a
ction
(
nullptr
)
,
m_save
_p
lot
_a
ction
(
nullptr
)
{
QVBoxLayout
*
vlayout
=
new
QVBoxLayout
(
this
);
vlayout
->
setMargin
(
0
);
vlayout
->
setSpacing
(
0
);
vlayout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
vlayout
->
addWidget
(
m_
customPlot
);
vlayout
->
addWidget
(
m_
plot_canvas
);
setLayout
(
vlayout
);
setStyleSheet
(
"background-color:white;"
);
initGraph
();
m_customPlot
->
xAxis
->
setTickLabelFont
(
QFont
(
QFont
().
family
(),
Constants
::
plot_tick_label_size
));
m_customPlot
->
yAxis
->
setTickLabelFont
(
QFont
(
QFont
().
family
(),
Constants
::
plot_tick_label_size
));
ColorMapUtils
::
setLogz
(
m_customPlot
->
yAxis
,
true
);
m_customPlot
->
xAxis
->
setLabel
(
"iteration"
);
m_customPlot
->
yAxis
->
setLabel
(
"chi2"
);
m_customPlot
->
xAxis
->
setLabelFont
(
QFont
(
QFont
().
family
(),
Constants
::
plot_axes_label_size
));
m_customPlot
->
yAxis
->
setLabelFont
(
QFont
(
QFont
().
family
(),
Constants
::
plot_axes_label_size
));
initActions
();
connect
(
m_customPlot
,
&
QCustomPlot
::
mousePress
,
this
,
connect
(
m_
plot_canvas
->
customPlot
()
,
&
QCustomPlot
::
mousePress
,
this
,
&
SpecularDataCanvas
::
onMousePress
,
Qt
::
UniqueConnection
);
}
void
SpecularDataCanvas
::
setItem
(
SessionItem
*
intensityItem
)
{
SessionItemWidget
::
setItem
(
intensityItem
);
initGraphFrom
Item
(
);
m_plot_canvas
->
setItem
(
intensity
Item
);
}
QSize
SpecularDataCanvas
::
sizeHint
()
const
{
return
QSize
(
500
,
400
);
}
...
...
@@ -66,7 +54,7 @@ QSize SpecularDataCanvas::minimumSizeHint() const { return QSize(128, 128); }
QList
<
QAction
*>
SpecularDataCanvas
::
actionList
()
{
return
QList
<
QAction
*>
()
<<
m_reset
V
iew
A
ction
<<
m_save
P
lot
A
ction
;
return
QList
<
QAction
*>
()
<<
m_reset
_v
iew
_a
ction
<<
m_save
_p
lot
_a
ction
;
}
void
SpecularDataCanvas
::
onResetViewAction
()
{
specularDataItem
()
->
resetView
();
}
...
...
@@ -75,7 +63,7 @@ void SpecularDataCanvas::onSavePlotAction()
{
QString
dirname
=
AppSvc
::
projectManager
()
->
userExportDir
();
SavePlotAssistant
saveAssistant
;
saveAssistant
.
savePlot
(
dirname
,
m_customPlot
,
specularDataItem
()
->
getOutputData
());
saveAssistant
.
savePlot
(
dirname
,
m_
plot_canvas
->
customPlot
()
,
specularDataItem
()
->
getOutputData
());
}
void
SpecularDataCanvas
::
onMousePress
(
QMouseEvent
*
event
)
...
...
@@ -91,31 +79,6 @@ void SpecularDataCanvas::onMousePress(QMouseEvent* event)
m_customPlot->replot();
}*/
void
SpecularDataCanvas
::
initGraph
()
{
m_customPlot
->
addGraph
();
QPen
pen
(
QColor
(
0
,
0
,
255
,
200
));
m_customPlot
->
graph
()
->
setLineStyle
(
QCPGraph
::
lsLine
);
m_customPlot
->
graph
()
->
setPen
(
pen
);
QFontMetrics
fontMetric
(
font
());
auto
em
=
fontMetric
.
width
(
'M'
),
fontAscent
=
fontMetric
.
ascent
();
auto
*
axisRectangle
=
m_customPlot
->
axisRect
();
axisRectangle
->
setAutoMargins
(
QCP
::
msTop
|
QCP
::
msBottom
);
axisRectangle
->
setMargins
(
QMargins
(
em
*
4
,
fontAscent
*
2
,
em
*
2
,
fontAscent
*
2
));
}
void
SpecularDataCanvas
::
initGraphFromItem
()
{
const
auto
underlying_data
=
specularDataItem
()
->
getOutputData
();
for
(
size_t
i
=
0
,
size
=
underlying_data
->
getAllocatedSize
();
i
<
size
;
++
i
)
{
double
x
=
underlying_data
->
getAxisValue
(
i
,
0
);
double
y
=
underlying_data
->
operator
[](
i
);
m_customPlot
->
graph
()
->
addData
(
x
,
y
);
}
}
SpecularDataItem
*
SpecularDataCanvas
::
specularDataItem
()
{
SpecularDataItem
*
result
=
dynamic_cast
<
SpecularDataItem
*>
(
currentItem
());
...
...
@@ -126,16 +89,16 @@ SpecularDataItem* SpecularDataCanvas::specularDataItem()
// TODO: try to reuse IntensityDataCanvas::initActions somehow
void
SpecularDataCanvas
::
initActions
()
{
m_reset
V
iew
A
ction
=
new
QAction
(
this
);
m_reset
V
iew
A
ction
->
setText
(
"Reset"
);
m_reset
V
iew
A
ction
->
setIcon
(
QIcon
(
":/images/toolbar16light_refresh.svg"
));
m_reset
V
iew
A
ction
->
setToolTip
(
"Reset view
\n
"
m_reset
_v
iew
_a
ction
=
new
QAction
(
this
);
m_reset
_v
iew
_a
ction
->
setText
(
"Reset"
);
m_reset
_v
iew
_a
ction
->
setIcon
(
QIcon
(
":/images/toolbar16light_refresh.svg"
));
m_reset
_v
iew
_a
ction
->
setToolTip
(
"Reset view
\n
"
"x,y,z axes range will be set to default"
);
connect
(
m_reset
V
iew
A
ction
,
&
QAction
::
triggered
,
this
,
&
SpecularDataCanvas
::
onResetViewAction
);
connect
(
m_reset
_v
iew
_a
ction
,
&
QAction
::
triggered
,
this
,
&
SpecularDataCanvas
::
onResetViewAction
);
m_save
P
lot
A
ction
=
new
QAction
(
this
);
m_save
P
lot
A
ction
->
setText
(
"Save"
);
m_save
P
lot
A
ction
->
setIcon
(
QIcon
(
":/images/toolbar16light_save.svg"
));
m_save
P
lot
A
ction
->
setToolTip
(
"Save plot"
);
connect
(
m_save
P
lot
A
ction
,
&
QAction
::
triggered
,
this
,
&
SpecularDataCanvas
::
onSavePlotAction
);
m_save
_p
lot
_a
ction
=
new
QAction
(
this
);
m_save
_p
lot
_a
ction
->
setText
(
"Save"
);
m_save
_p
lot
_a
ction
->
setIcon
(
QIcon
(
":/images/toolbar16light_save.svg"
));
m_save
_p
lot
_a
ction
->
setToolTip
(
"Save plot"
);
connect
(
m_save
_p
lot
_a
ction
,
&
QAction
::
triggered
,
this
,
&
SpecularDataCanvas
::
onSavePlotAction
);
}
This diff is collapsed.
Click to expand it.
GUI/coregui/Views/SpecularDataWidgets/SpecularDataCanvas.h
+
4
−
6
View file @
b549ec60
...
...
@@ -17,10 +17,10 @@
#include
"SessionItemWidget.h"
#include
"WinDllMacros.h"
#include
"qcustomplot.h"
#include
<QWidget>
class
SpecularDataItem
;
class
SpecularPlotCanvas
;
class
BA_CORE_API_
SpecularDataCanvas
:
public
SessionItemWidget
{
...
...
@@ -42,14 +42,12 @@ public slots:
//void clearData();
private:
void
initGraph
();
void
initGraphFromItem
();
SpecularDataItem
*
specularDataItem
();
void
initActions
();
QCustomPlot
*
m_customPlot
;
QAction
*
m_reset
V
iew
A
ction
;
QAction
*
m_save
P
lot
A
ction
;
SpecularPlotCanvas
*
m_plot_canvas
;
QAction
*
m_reset
_v
iew
_a
ction
;
QAction
*
m_save
_p
lot
_a
ction
;
};
#endif // SPECULARDATACANVAS_H
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