Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenFlipper-Free
OpenFlipper
Commits
953ee670
Commit
953ee670
authored
May 06, 2016
by
Hans-Christian Ebke
Browse files
Added fully scriptable viewer snapshot slot to core.
parent
3d5ad4d7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Core/Core.cc
View file @
953ee670
...
...
@@ -1456,6 +1456,21 @@ void Core::viewerSnapshot(){
coreWidget_
->
viewerSnapshot
();
}
void
Core
::
viewerSnapshot
(
QString
file_name
,
bool
store_comments
,
bool
comments_visible_only
,
bool
comments_targeted_only
,
bool
store_material_info
,
bool
snapshot_width
,
bool
snapshot_height
,
bool
snapshot_transparent
,
bool
hide_coord_sys
,
int
snapshot_multisampling
,
bool
store_view
)
{
if
(
OpenFlipper
::
Options
::
gui
()
)
coreWidget_
->
viewerSnapshot
(
file_name
,
store_comments
,
comments_visible_only
,
comments_targeted_only
,
store_material_info
,
snapshot_width
,
snapshot_height
,
snapshot_transparent
,
hide_coord_sys
,
snapshot_multisampling
,
store_view
);
}
void
Core
::
resizeViewers
(
int
_width
,
int
_height
){
if
(
OpenFlipper
::
Options
::
gui
()
){
...
...
Core/Core.hh
View file @
953ee670
...
...
@@ -719,6 +719,13 @@ public slots:
/// Take a snapshot from all viewers
void
viewerSnapshot
();
/// Scriptable snapshot method offering full control
void
viewerSnapshot
(
QString
file_name
,
bool
store_comments
,
bool
comments_visible_only
,
bool
comments_targeted_only
,
bool
store_material_info
,
bool
snapshot_width
,
bool
snapshot_height
,
bool
snapshot_transparent
,
bool
hide_coord_sys
,
int
snapshot_multisampling
,
bool
store_view
);
/// resize the examinerViewer
void
resizeViewers
(
int
_width
,
int
_height
);
...
...
widgets/coreWidget/CoreWidget.hh
View file @
953ee670
...
...
@@ -1022,6 +1022,12 @@ public:
/// Set the snapshot name
void
applicationSnapshotName
(
QString
_name
);
/// Scriptable snapshot method offering full control
void
viewerSnapshot
(
QString
file_name
,
bool
store_comments
,
bool
comments_visible_only
,
bool
comments_targeted_only
,
bool
store_material_info
,
bool
snapshot_width
,
bool
snapshot_height
,
bool
snapshot_transparent
,
bool
hide_coord_sys
,
int
snapshot_multisampling
,
bool
store_view
);
/** @} */
...
...
widgets/coreWidget/viewerControl.cc
View file @
953ee670
...
...
@@ -541,39 +541,32 @@ void CoreWidget::applicationSnapshot() {
writeImageAsynchronously
(
pic
,
suggestSnapshotFilename
(
snapshotName_
));
}
///Take a snapshot of all viewers
void
CoreWidget
::
viewerSnapshotDialog
()
{
int
w
=
glView_
->
width
();
int
h
=
glView_
->
height
();
SnapshotDialog
dialog
(
suggestSnapshotFilename
(
snapshotName_
),
true
,
w
,
h
,
0
);
if
(
!
ACG
::
SceneGraph
::
Material
::
support_json_serialization
())
dialog
.
metaData_storeMatInfo_cb
->
setVisible
(
false
);
bool
ok
=
dialog
.
exec
();
if
(
ok
){
QString
newName
=
dialog
.
filename
->
text
();
void
CoreWidget
::
viewerSnapshot
(
QString
file_ame
,
bool
store_comments
,
bool
comments_visible_only
,
bool
comments_targeted_only
,
bool
store_material_info
,
bool
snapshot_width
,
bool
snapshot_height
,
bool
snapshot_transparent
,
bool
hide_coord_sys
,
int
snapshot_multisampling
,
bool
store_view
)
{
if
(
snapshot_height
<
0
)
{
int
w
=
glView_
->
width
();
int
h
=
glView_
->
height
();
snapshot_height
=
snapshot_width
/
w
*
h
;
}
OpenFlipperSettings
().
setValue
(
"Core/CurrentDir"
,
QFileInfo
(
newName
).
absolutePath
()
);
snapshotName_
=
newName
;
QString
comments
;
if
(
dialog
.
metaData_
store
C
omments
_cb
->
isChecked
()
)
{
if
(
store
_c
omments
)
{
comments
=
PluginFunctions
::
collectObjectComments
(
dialog
.
metaData_
comments_visible
O
nly
_cb
->
isChecked
()
,
dialog
.
metaData_
comments_targeted
O
nly
_cb
->
isChecked
()
).
join
(
"
\n
"
);
comments_visible
_o
nly
,
comments_targeted
_o
nly
).
join
(
"
\n
"
);
}
QString
materials
;
if
(
ACG
::
SceneGraph
::
Material
::
support_json_serialization
()
&&
//if (ACG::SceneGraph::Material::CP_JSON_SERIALIZABLE &&
dialog
.
metaData_storeMatInfo_cb
->
isChecked
()
)
{
store_material_info
)
{
materials
=
PluginFunctions
::
collectObjectMaterials
(
dialog
.
metaData_
comments_visible
O
nly
_cb
->
isChecked
()
,
dialog
.
metaData_
comments_targeted
O
nly
_cb
->
isChecked
()
).
join
(
"
\n
"
);
comments_visible
_o
nly
,
comments_targeted
_o
nly
).
join
(
"
\n
"
);
}
//now take the snapshot
...
...
@@ -584,15 +577,15 @@ void CoreWidget::viewerSnapshotDialog() {
QImage
finalImage
;
examiner_widgets_
[
PluginFunctions
::
activeExaminer
()]
->
snapshot
(
finalImage
,
dialog
.
snapWidth
->
value
(),
dialog
.
snapHeight
->
value
()
,
dialog
.
transparent
->
isChecked
(),
dialog
.
hide
C
oordsys
->
isChecked
()
,
dialog
.
multisampling
->
isChecked
()
?
dialog
.
num_samples
->
value
()
:
1
);
snapshot_width
,
snapshot_height
,
snapshot_
transparent
,
hide
_c
oord
_
sys
,
snapshot_
multisampling
);
if
(
!
comments
.
isEmpty
())
finalImage
.
setText
(
"Mesh Comments"
,
comments
);
if
(
!
materials
.
isEmpty
())
finalImage
.
setText
(
"Mesh Materials"
,
materials
);
if
(
dialog
.
metaData_
store
V
iew
_cb
->
isChecked
()
)
{
if
(
store
_v
iew
)
{
QSize
window_size
;
if
(
isMaximized
())
window_size
=
QSize
(
-
width
(),
-
height
());
...
...
@@ -609,63 +602,75 @@ void CoreWidget::viewerSnapshotDialog() {
examiner_widgets_
[
PluginFunctions
::
activeExaminer
()]
->
encodeView
(
view
,
window_size
,
splitter_size
);
finalImage
.
setText
(
"View"
,
view
);
}
finalImage
.
save
(
newN
ame
);
finalImage
.
save
(
file_
ame
);
break
;
}
case
QtMultiViewLayout
::
DoubleView
:
{
int
w
=
dialog
.
snapHeight
->
value
()
;
int
w
=
snapshot_height
;
double
relSizeW
=
static_cast
<
double
>
(
examiner_widgets_
[
0
]
->
glWidth
()
/
static_cast
<
double
>
(
glScene_
->
width
()
)
);
double
relSizeW
=
static_cast
<
double
>
(
examiner_widgets_
[
0
]
->
glWidth
()
/
static_cast
<
double
>
(
glScene_
->
width
()
)
);
//Get the images
QImage
img
[
2
];
examiner_widgets_
[
0
]
->
snapshot
(
img
[
0
],
static_cast
<
int
>
(
relSizeW
*
w
)
,
dialog
.
snapWidth
->
value
(),
dialog
.
transparent
->
isChecked
(),
dialog
.
hideCoordsys
->
isChecked
());
examiner_widgets_
[
1
]
->
snapshot
(
img
[
1
],
static_cast
<
int
>
(
relSizeW
*
w
)
,
dialog
.
snapWidth
->
value
(),
dialog
.
transparent
->
isChecked
(),
dialog
.
hideCoordsys
->
isChecked
());
//Get the images
QImage
img
[
2
];
examiner_widgets_
[
0
]
->
snapshot
(
img
[
0
],
static_cast
<
int
>
(
relSizeW
*
w
),
snapshot_width
,
snapshot_transparent
,
hide_coord_sys
);
examiner_widgets_
[
1
]
->
snapshot
(
img
[
1
],
static_cast
<
int
>
(
relSizeW
*
w
),
snapshot_width
,
snapshot_transparent
,
hide_coord_sys
);
QImage
finalImage
(
img
[
0
].
width
()
+
img
[
1
].
width
()
+
2
,
img
[
0
].
height
(),
QImage
::
Format_ARGB32_Premultiplied
);
QImage
finalImage
(
img
[
0
].
width
()
+
img
[
1
].
width
()
+
2
,
img
[
0
].
height
(),
QImage
::
Format_ARGB32_Premultiplied
);
QPainter
painter
(
&
finalImage
);
QPainter
painter
(
&
finalImage
);
painter
.
fillRect
(
0
,
0
,
finalImage
.
width
(),
finalImage
.
height
(),
QBrush
(
Qt
::
gray
));
painter
.
fillRect
(
0
,
0
,
finalImage
.
width
(),
finalImage
.
height
(),
QBrush
(
Qt
::
gray
));
painter
.
drawImage
(
QRectF
(
0
,
0
,
img
[
0
].
width
(),
img
[
0
].
height
()),
img
[
0
],
QRectF
(
0
,
0
,
img
[
0
].
width
(),
img
[
0
].
height
())
);
painter
.
drawImage
(
QRectF
(
img
[
0
].
width
()
+
2
,
0
,
img
[
1
].
width
(),
img
[
1
].
height
()),
img
[
1
],
QRectF
(
0
,
0
,
img
[
1
].
width
(),
img
[
1
].
height
())
);
painter
.
drawImage
(
QRectF
(
0
,
0
,
img
[
0
].
width
(),
img
[
0
].
height
()),
img
[
0
],
QRectF
(
0
,
0
,
img
[
0
].
width
(),
img
[
0
].
height
())
);
painter
.
drawImage
(
QRectF
(
img
[
0
].
width
()
+
2
,
0
,
img
[
1
].
width
(),
img
[
1
].
height
()),
img
[
1
],
QRectF
(
0
,
0
,
img
[
1
].
width
(),
img
[
1
].
height
())
);
if
(
!
comments
.
isEmpty
())
finalImage
.
setText
(
"Mesh Comments"
,
comments
);
finalImage
.
save
(
newN
ame
);
finalImage
.
save
(
file_
ame
);
break
;
break
;
}
case
QtMultiViewLayout
::
Grid
:
{
// Compute size of each viewer
int
w
=
dialog
.
snapWidth
->
value
();
int
h
=
dialog
.
snapHeight
->
value
();
// Relative size of first viewer (in relation to the other viewers
double
relSizeW
=
(
double
)
examiner_widgets_
[
0
]
->
glWidth
()
/
(
double
)
glScene_
->
width
();
double
relSizeH
=
(
double
)
examiner_widgets_
[
0
]
->
glHeight
()
/
(
double
)
glScene_
->
height
();
QImage
img0
,
img1
,
img2
,
img3
;
examiner_widgets_
[
0
]
->
snapshot
(
img0
,
(
int
)((
double
)
w
*
relSizeW
),
(
int
)((
double
)
h
*
relSizeH
),
dialog
.
transparent
->
isChecked
(),
dialog
.
hideCoordsys
->
isChecked
());
examiner_widgets_
[
1
]
->
snapshot
(
img1
,
(
int
)((
double
)
w
*
(
1.0
-
relSizeW
)),
(
int
)((
double
)
h
*
relSizeH
),
dialog
.
transparent
->
isChecked
(),
dialog
.
hideCoordsys
->
isChecked
());
examiner_widgets_
[
2
]
->
snapshot
(
img2
,
(
int
)((
double
)
w
*
relSizeW
),
(
int
)((
double
)
h
*
(
1.0
-
relSizeH
)),
dialog
.
transparent
->
isChecked
(),
dialog
.
hideCoordsys
->
isChecked
());
examiner_widgets_
[
3
]
->
snapshot
(
img3
,
(
int
)((
double
)
w
*
(
1.0
-
relSizeW
)),
(
int
)((
double
)
h
*
(
1.0
-
relSizeH
)),
dialog
.
transparent
->
isChecked
(),
dialog
.
hideCoordsys
->
isChecked
());
QImage
finalImage
(
img0
.
width
()
+
img1
.
width
()
+
2
,
img0
.
height
()
+
img2
.
height
()
+
2
,
QImage
::
Format_ARGB32_Premultiplied
);
examiner_widgets_
[
0
]
->
snapshot
(
img0
,
(
int
)((
double
)
snapshot_width
*
relSizeW
),
(
int
)((
double
)
snapshot_height
*
relSizeH
),
snapshot_transparent
,
hide_coord_sys
);
examiner_widgets_
[
1
]
->
snapshot
(
img1
,
(
int
)((
double
)
snapshot_width
*
(
1.0
-
relSizeW
)),
(
int
)((
double
)
snapshot_height
*
relSizeH
),
snapshot_transparent
,
hide_coord_sys
);
examiner_widgets_
[
2
]
->
snapshot
(
img2
,
(
int
)((
double
)
snapshot_width
*
relSizeW
),
(
int
)((
double
)
snapshot_height
*
(
1.0
-
relSizeH
)),
snapshot_transparent
,
hide_coord_sys
);
examiner_widgets_
[
3
]
->
snapshot
(
img3
,
(
int
)((
double
)
snapshot_width
*
(
1.0
-
relSizeW
)),
(
int
)((
double
)
snapshot_height
*
(
1.0
-
relSizeH
)),
snapshot_transparent
,
hide_coord_sys
);
QImage
finalImage
(
img0
.
width
()
+
img1
.
width
()
+
2
,
img0
.
height
()
+
img2
.
height
()
+
2
,
QImage
::
Format_ARGB32_Premultiplied
);
QPainter
painter
(
&
finalImage
);
...
...
@@ -682,16 +687,12 @@ void CoreWidget::viewerSnapshotDialog() {
if
(
!
comments
.
isEmpty
())
finalImage
.
setText
(
"Mesh Comments"
,
comments
);
finalImage
.
save
(
newN
ame
);
finalImage
.
save
(
file_
ame
);
break
;
}
case
QtMultiViewLayout
::
HSplit
:
{
// Compute size of each viewer
int
w
=
dialog
.
snapWidth
->
value
();
int
h
=
dialog
.
snapHeight
->
value
();
// Relative size of first viewer (in relation to the other viewers
double
relSizeW
=
(
double
)
examiner_widgets_
[
0
]
->
glWidth
()
/
(
double
)
glScene_
->
width
();
double
relSizeH1
=
(
double
)
examiner_widgets_
[
1
]
->
glHeight
()
/
(
double
)
glScene_
->
height
();
...
...
@@ -700,14 +701,21 @@ void CoreWidget::viewerSnapshotDialog() {
QImage
img0
,
img1
,
img2
,
img3
;
examiner_widgets_
[
0
]
->
snapshot
(
img0
,
(
int
)((
double
)
w
*
relSizeW
),
h
,
dialog
.
transparent
->
isChecked
(),
dialog
.
hideCoordsys
->
isChecked
());
examiner_widgets_
[
1
]
->
snapshot
(
img1
,
(
int
)((
double
)
w
*
(
1.0
-
relSizeW
)),
relSizeH1
*
(
double
)
h
,
dialog
.
transparent
->
isChecked
(),
dialog
.
hideCoordsys
->
isChecked
());
examiner_widgets_
[
2
]
->
snapshot
(
img2
,
(
int
)((
double
)
w
*
(
1.0
-
relSizeW
)),
relSizeH2
*
(
double
)
h
,
dialog
.
transparent
->
isChecked
(),
dialog
.
hideCoordsys
->
isChecked
());
examiner_widgets_
[
3
]
->
snapshot
(
img3
,
(
int
)((
double
)
w
*
(
1.0
-
relSizeW
)),
relSizeH3
*
(
double
)
h
,
dialog
.
transparent
->
isChecked
(),
dialog
.
hideCoordsys
->
isChecked
());
examiner_widgets_
[
0
]
->
snapshot
(
img0
,
(
int
)((
double
)
snapshot_width
*
relSizeW
),
snapshot_height
,
snapshot_transparent
,
hide_coord_sys
);
examiner_widgets_
[
1
]
->
snapshot
(
img1
,
(
int
)((
double
)
snapshot_width
*
(
1.0
-
relSizeW
)),
relSizeH1
*
(
double
)
snapshot_height
,
snapshot_transparent
,
hide_coord_sys
);
examiner_widgets_
[
2
]
->
snapshot
(
img2
,
(
int
)((
double
)
snapshot_width
*
(
1.0
-
relSizeW
)),
relSizeH2
*
(
double
)
snapshot_height
,
snapshot_transparent
,
hide_coord_sys
);
examiner_widgets_
[
3
]
->
snapshot
(
img3
,
(
int
)((
double
)
snapshot_width
*
(
1.0
-
relSizeW
)),
relSizeH3
*
(
double
)
snapshot_height
,
snapshot_transparent
,
hide_coord_sys
);
QImage
finalImage
(
img0
.
width
()
+
img1
.
width
()
+
2
,
img0
.
height
(),
QImage
::
Format_ARGB32_Premultiplied
);
...
...
@@ -726,13 +734,54 @@ void CoreWidget::viewerSnapshotDialog() {
if
(
!
comments
.
isEmpty
())
finalImage
.
setText
(
"Mesh Comments"
,
comments
);
finalImage
.
save
(
newN
ame
);
finalImage
.
save
(
file_
ame
);
break
;
}
default:
break
;
}
}
///Take a snapshot of all viewers
void
CoreWidget
::
viewerSnapshotDialog
()
{
int
w
=
glView_
->
width
();
int
h
=
glView_
->
height
();
SnapshotDialog
dialog
(
suggestSnapshotFilename
(
snapshotName_
),
true
,
w
,
h
,
0
);
if
(
!
ACG
::
SceneGraph
::
Material
::
support_json_serialization
())
dialog
.
metaData_storeMatInfo_cb
->
setVisible
(
false
);
bool
ok
=
dialog
.
exec
();
if
(
ok
){
QString
newName
=
dialog
.
filename
->
text
();
OpenFlipperSettings
().
setValue
(
"Core/CurrentDir"
,
QFileInfo
(
newName
).
absolutePath
()
);
snapshotName_
=
newName
;
const
bool
storeComments
=
dialog
.
metaData_storeComments_cb
->
isChecked
();
const
bool
comments_visible_only
=
dialog
.
metaData_comments_visibleOnly_cb
->
isChecked
();
const
bool
comments_targeted_only
=
dialog
.
metaData_comments_targetedOnly_cb
->
isChecked
();
const
bool
store_material_info
=
dialog
.
metaData_storeMatInfo_cb
->
isChecked
();
const
bool
snapshot_width
=
dialog
.
snapWidth
->
value
();
const
bool
snapshot_height
=
dialog
.
snapHeight
->
value
();
const
bool
snapshot_transparent
=
dialog
.
transparent
->
isChecked
();
const
bool
hide_coord_sys
=
dialog
.
hideCoordsys
->
isChecked
();
const
int
snapshot_multisampling
=
dialog
.
multisampling
->
isChecked
()
?
dialog
.
num_samples
->
value
()
:
1
;
const
bool
store_view
=
dialog
.
metaData_storeView_cb
->
isChecked
();
viewerSnapshot
(
newName
,
storeComments
,
comments_visible_only
,
comments_targeted_only
,
store_material_info
,
snapshot_width
,
snapshot_height
,
snapshot_transparent
,
hide_coord_sys
,
snapshot_multisampling
,
store_view
);
}
//glView_->resize(w, h);
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment