OGS
StratView.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include "StratView.h"
5
6#include <math.h>
7
8#include "GeoLib/Station.h"
9
11{
12 delete _scene;
13}
14
17 std::map<std::string, DataHolderLib::Color>* stratColors)
18{
19 _scene = new StratScene(station, stratColors);
20 setScene(_scene);
21 initialize();
22}
23
25{
26 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
27 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
28
29 update();
30}
31
32void StratView::resizeEvent(QResizeEvent* event)
33{
34 Q_UNUSED(event)
35 update();
36}
37
39{
40 QRectF viewRect = _scene->itemsBoundingRect();
41 _scene->setSceneRect(viewRect);
42 QRectF sceneInView(StratScene::MARGIN, StratScene::MARGIN,
43 viewRect.width() + 2 * StratScene::MARGIN,
44 viewRect.height() + 2 * StratScene::MARGIN);
45 fitInView(sceneInView, Qt::IgnoreAspectRatio);
46}
47
48void StratView::saveAsImage(QString fileName)
49{
50 this->update();
51
52 QRectF viewRect = _scene->itemsBoundingRect();
53 QImage img(static_cast<int>(viewRect.width()) + 2 * StratScene::MARGIN, 600,
54 QImage::Format_ARGB32);
55 QPainter painter(&img);
56
57 this->render(&painter);
58 img.save(fileName);
59}
A borehole as a geometric object.
The scene for the visualisation of the stratigraphy of a borehole.
Definition StratScene.h:18
static const int MARGIN
The margin between the boundary of the scene and the bounding box of all items within the scene.
Definition StratScene.h:28
~StratView() override
Definition StratView.cpp:10
void saveAsImage(QString fileName)
Definition StratView.cpp:48
void update()
Updates the view automatically when a Borehole is added or when the window containing the view change...
Definition StratView.cpp:38
void initialize()
Initialises the view.
Definition StratView.cpp:24
StratScene * _scene
Definition StratView.h:64
void setStation(GeoLib::StationBorehole *station, std::map< std::string, DataHolderLib::Color > *stratColors=nullptr)
Sets the Borehole whose data should be visualised.
Definition StratView.cpp:15
void resizeEvent(QResizeEvent *event) override
Resizes the scene.
Definition StratView.cpp:32