OGS
StratView.cpp
Go to the documentation of this file.
1
15#include "StratView.h"
16
17#include <math.h>
18
19#include "GeoLib/Station.h"
20
22{
23 delete _scene;
24}
25
28 std::map<std::string, DataHolderLib::Color>* stratColors)
29{
30 _scene = new StratScene(station, stratColors);
31 setScene(_scene);
32 initialize();
33}
34
36{
37 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
38 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
39
40 update();
41}
42
43void StratView::resizeEvent(QResizeEvent* event)
44{
45 Q_UNUSED(event)
46 update();
47}
48
50{
51 QRectF viewRect = _scene->itemsBoundingRect();
52 _scene->setSceneRect(viewRect);
53 QRectF sceneInView(StratScene::MARGIN, StratScene::MARGIN,
54 viewRect.width() + 2 * StratScene::MARGIN,
55 viewRect.height() + 2 * StratScene::MARGIN);
56 fitInView(sceneInView, Qt::IgnoreAspectRatio);
57}
58
59void StratView::saveAsImage(QString fileName)
60{
61 this->update();
62
63 QRectF viewRect = _scene->itemsBoundingRect();
64 QImage img(static_cast<int>(viewRect.width()) + 2 * StratScene::MARGIN, 600,
65 QImage::Format_ARGB32);
66 QPainter painter(&img);
67
68 this->render(&painter);
69 img.save(fileName);
70}
Definition of the Station class.
Definition of the StratView class.
A borehole as a geometric object.
The scene for the visualisation of the stratigraphy of a borehole.
Definition StratScene.h:29
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:39
~StratView() override
Definition StratView.cpp:21
void saveAsImage(QString fileName)
Definition StratView.cpp:59
void update()
Updates the view automatically when a Borehole is added or when the window containing the view change...
Definition StratView.cpp:49
void initialize()
Initialises the view.
Definition StratView.cpp:35
StratScene * _scene
Definition StratView.h:75
void setStation(GeoLib::StationBorehole *station, std::map< std::string, DataHolderLib::Color > *stratColors=nullptr)
Sets the Borehole whose data should be visualised.
Definition StratView.cpp:26
void resizeEvent(QResizeEvent *event) override
Resizes the scene.
Definition StratView.cpp:43