OGS
StratView Class Reference

Detailed Description

A view in which to display the stratigraphy of a borehole.

Definition at line 30 of file StratView.h.

#include <StratView.h>

Inheritance diagram for StratView:
[legend]
Collaboration diagram for StratView:
[legend]

Public Member Functions

 StratView (QWidget *parent=nullptr)
 
 ~StratView () override
 
void setStation (GeoLib::StationBorehole *station, std::map< std::string, DataHolderLib::Color > *stratColors=nullptr)
 Sets the Borehole whose data should be visualised.
 
int getHeight ()
 Returns the height of the bounding rectangle of all objects within the scene.
 
int getWidth ()
 Returns the width of the bounding rectangle of all objects within the scene.
 
void saveAsImage (QString fileName)
 

Protected Member Functions

void resizeEvent (QResizeEvent *event) override
 Resizes the scene.
 

Private Member Functions

void initialize ()
 Initialises the view.
 
QSize minimumSizeHint () const override
 The minimum size of the window.
 
QSize sizeHint () const override
 The default size of the window.
 
void update ()
 Updates the view automatically when a Borehole is added or when the window containing the view changes its state.
 

Private Attributes

StratScene_scene {nullptr}
 

Constructor & Destructor Documentation

◆ StratView()

StratView::StratView ( QWidget * parent = nullptr)
inlineexplicit

Creates an empty view.

Definition at line 37 of file StratView.h.

37{ Q_UNUSED(parent); }

◆ ~StratView()

StratView::~StratView ( )
override

Definition at line 21 of file StratView.cpp.

22{
23 delete _scene;
24}
StratScene * _scene
Definition StratView.h:75

References _scene.

Member Function Documentation

◆ getHeight()

int StratView::getHeight ( )
inline

Returns the height of the bounding rectangle of all objects within the scene.

Definition at line 45 of file StratView.h.

45{ return static_cast<int>((_scene->itemsBoundingRect()).height()); }

References _scene.

◆ getWidth()

int StratView::getWidth ( )
inline

Returns the width of the bounding rectangle of all objects within the scene.

Definition at line 48 of file StratView.h.

48{ return static_cast<int>((_scene->itemsBoundingRect()).width()); }

References _scene.

◆ initialize()

void StratView::initialize ( )
private

Initialises the view.

Definition at line 35 of file StratView.cpp.

36{
37 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
38 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
39
40 update();
41}
void update()
Updates the view automatically when a Borehole is added or when the window containing the view change...
Definition StratView.cpp:49

References update().

Referenced by setStation().

◆ minimumSizeHint()

QSize StratView::minimumSizeHint ( ) const
inlineoverrideprivate

The minimum size of the window.

Definition at line 61 of file StratView.h.

62 {
63 return QSize(3 * _scene->MARGIN, 2 * _scene->MARGIN);
64 }
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

References _scene, and StratScene::MARGIN.

◆ resizeEvent()

void StratView::resizeEvent ( QResizeEvent * event)
overrideprotected

Resizes the scene.

Definition at line 43 of file StratView.cpp.

44{
45 Q_UNUSED(event)
46 update();
47}

References update().

◆ saveAsImage()

void StratView::saveAsImage ( QString fileName)

Definition at line 59 of file StratView.cpp.

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}

References _scene, StratScene::MARGIN, and update().

◆ setStation()

void StratView::setStation ( GeoLib::StationBorehole * station,
std::map< std::string, DataHolderLib::Color > * stratColors = nullptr )

Sets the Borehole whose data should be visualised.

Definition at line 26 of file StratView.cpp.

29{
30 _scene = new StratScene(station, stratColors);
31 setScene(_scene);
32 initialize();
33}
The scene for the visualisation of the stratigraphy of a borehole.
Definition StratScene.h:29
void initialize()
Initialises the view.
Definition StratView.cpp:35

References _scene, and initialize().

◆ sizeHint()

QSize StratView::sizeHint ( ) const
inlineoverrideprivate

The default size of the window.

Definition at line 67 of file StratView.h.

68 {
69 return QSize(6 * _scene->MARGIN, 4 * _scene->MARGIN);
70 }

References _scene, and StratScene::MARGIN.

◆ update()

void StratView::update ( )
private

Updates the view automatically when a Borehole is added or when the window containing the view changes its state.

Definition at line 49 of file StratView.cpp.

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}

References _scene, and StratScene::MARGIN.

Referenced by initialize(), resizeEvent(), and saveAsImage().

Member Data Documentation

◆ _scene

StratScene* StratView::_scene {nullptr}
private

Definition at line 75 of file StratView.h.

75{nullptr};

Referenced by ~StratView(), getHeight(), getWidth(), minimumSizeHint(), saveAsImage(), setStation(), sizeHint(), and update().


The documentation for this class was generated from the following files: