OGS
StratScene Class Reference

Detailed Description

The scene for the visualisation of the stratigraphy of a borehole.

Definition at line 17 of file StratScene.h.

#include <StratScene.h>

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

Public Member Functions

 StratScene (GeoLib::StationBorehole *station, std::map< std::string, DataHolderLib::Color > *stratColors=nullptr, QObject *parent=nullptr)
 Constructor.
 ~StratScene () override

Static Public Attributes

static const int MARGIN = 50
 The margin between the boundary of the scene and the bounding box of all items within the scene.

Private Member Functions

void addDepthLabels (std::vector< GeoLib::Point * > profile, double offset)
 Adds text labels indicating the depth at the beginning and end of each soil layer.
QNonScalableGraphicsTextItemaddNonScalableText (const QString &text, const QFont &font=QFont())
 Add a non-scalable text item to the scene.
void addSoilNameLabels (std::vector< std::string > soilNames, std::vector< GeoLib::Point * > profile, double offset)
 Adds text labels indicating the name of each soil layer.
StratBaraddStratBar (GeoLib::StationBorehole *station, std::map< std::string, DataHolderLib::Color > *stratColors=nullptr)
 Add a stratigraphy-bar to the scene.

Constructor & Destructor Documentation

◆ StratScene()

StratScene::StratScene ( GeoLib::StationBorehole * station,
std::map< std::string, DataHolderLib::Color > * stratColors = nullptr,
QObject * parent = nullptr )
explicit

Constructor.

Definition at line 15 of file StratScene.cpp.

18 : QGraphicsScene(parent)
19{
20 QRectF textBounds;
21 int stratBarOffset = 250;
22
23 QFont font("Arial", 15, QFont::DemiBold, false);
24
25 QNonScalableGraphicsTextItem* boreholeTag =
26 addNonScalableText("Borehole", font);
27 QNonScalableGraphicsTextItem* boreholeName = addNonScalableText(
28 "\"" + QString::fromStdString(station->getName()) + "\"", font);
29 textBounds = boreholeTag->boundingRect();
30 boreholeTag->setPos((textBounds.width() / 2.0), 80);
31 textBounds = boreholeName->boundingRect();
32 boreholeName->setPos((textBounds.width() / 2.0), 200);
33
34 QNonScalableGraphicsTextItem* totalDepth = addNonScalableText(
35 "Depth: " + QString::number(station->getDepth()) + " m");
36 textBounds = totalDepth->boundingRect();
37 totalDepth->setPos((textBounds.width() / 2.0), 350);
38 /*
39 QNonScalableGraphicsTextItem* dateText = addNonScalableText("Date: " +
40 QString::fromStdString(date2string(station->getDate()))); textBounds =
41 dateText->boundingRect(); dateText->setPos(this->MARGIN +
42 (textBounds.width()/2.0), 350);
43 */
44 QNonScalableGraphicsTextItem* dot = addNonScalableText(" ");
45 dot->setPos(0, 0);
46
47 StratBar* stratBar = addStratBar(station, stratColors);
48 stratBar->setPos(stratBarOffset, MARGIN);
49 QRectF stratBarBounds = stratBar->boundingRect();
50
51 addDepthLabels(station->getProfile(),
52 stratBarOffset + stratBarBounds.width());
53
54 if (!station->getSoilNames().empty())
55 {
56 addSoilNameLabels(station->getSoilNames(), station->getProfile(),
57 stratBarOffset + (stratBarBounds.width() / 2));
58 }
59}
const std::vector< std::string > & getSoilNames() const
const std::vector< Point * > & getProfile() const
std::string const & getName() const
Returns the name of the station.
Definition Station.h:49
QRectF boundingRect() const override
Returns the bounding rectangle of the text item.
QRectF boundingRect() const override
Returns the bounding rectangle of the bar.
Definition StratBar.cpp:19
QNonScalableGraphicsTextItem * addNonScalableText(const QString &text, const QFont &font=QFont())
Add a non-scalable text item to the scene.
void addSoilNameLabels(std::vector< std::string > soilNames, std::vector< GeoLib::Point * > profile, double offset)
Adds text labels indicating the name of each soil layer.
void addDepthLabels(std::vector< GeoLib::Point * > profile, double offset)
Adds text labels indicating the depth at the beginning and end of each soil layer.
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
StratBar * addStratBar(GeoLib::StationBorehole *station, std::map< std::string, DataHolderLib::Color > *stratColors=nullptr)
Add a stratigraphy-bar to the scene.

References addDepthLabels(), addNonScalableText(), addSoilNameLabels(), addStratBar(), QNonScalableGraphicsTextItem::boundingRect(), StratBar::boundingRect(), GeoLib::StationBorehole::getDepth(), GeoLib::Station::getName(), GeoLib::StationBorehole::getProfile(), GeoLib::StationBorehole::getSoilNames(), and MARGIN.

◆ ~StratScene()

StratScene::~StratScene ( )
overridedefault

Member Function Documentation

◆ addDepthLabels()

void StratScene::addDepthLabels ( std::vector< GeoLib::Point * > profile,
double offset )
private

Adds text labels indicating the depth at the beginning and end of each soil layer.

Definition at line 63 of file StratScene.cpp.

65{
66 QRectF textBounds;
67 double vertPos = MARGIN;
68 std::vector<QNonScalableGraphicsTextItem*> depthText;
69 depthText.push_back(
70 addNonScalableText(QString::number((*(profile[0]))[2])));
71 textBounds = depthText[0]->boundingRect();
72 depthText[0]->setPos(offset + textBounds.width() / 2, vertPos);
73
74 for (std::size_t i = 1; i < profile.size(); i++)
75 {
76 depthText.push_back(
77 addNonScalableText(QString::number((*(profile[i]))[2])));
78 vertPos += log((*(profile[i - 1]))[2] - (*(profile[i]))[2] + 1) * 100;
79 textBounds = depthText[i]->boundingRect();
80 depthText[i]->setPos(offset + textBounds.width() / 2, vertPos);
81 }
82}

References addNonScalableText(), and MARGIN.

Referenced by StratScene().

◆ addNonScalableText()

QNonScalableGraphicsTextItem * StratScene::addNonScalableText ( const QString & text,
const QFont & font = QFont() )
private

Add a non-scalable text item to the scene.

Definition at line 84 of file StratScene.cpp.

86{
87 auto* item = new QNonScalableGraphicsTextItem(text);
88 item->setFont(font);
89 addItem(item);
90 return item;
91}

Referenced by StratScene(), addDepthLabels(), and addSoilNameLabels().

◆ addSoilNameLabels()

void StratScene::addSoilNameLabels ( std::vector< std::string > soilNames,
std::vector< GeoLib::Point * > profile,
double offset )
private

Adds text labels indicating the name of each soil layer.

Definition at line 93 of file StratScene.cpp.

97{
98 // QRectF textBounds;
99 double vertPos = MARGIN;
100 double halfHeight = 0;
101 std::vector<QNonScalableGraphicsTextItem*> soilText;
102 soilText.push_back(
103 addNonScalableText(QString::fromStdString(soilNames[0])));
104 // textBounds = soilText[0]->boundingRect();
105 soilText[0]->setPos(offset /* - textBounds.width() */, vertPos);
106
107 for (std::size_t i = 1; i < soilNames.size(); i++)
108 {
109 soilText.push_back(
110 addNonScalableText(QString::fromStdString(soilNames[i])));
111 halfHeight =
112 log((*(profile[i - 1]))[2] - (*(profile[i]))[2] + 1) * 100 / 2;
113 // textBounds = soilText[i]->boundingRect();
114 soilText[i]->setPos(offset /* - textBounds.width() */,
115 vertPos + halfHeight);
116 vertPos += (2 * halfHeight);
117 }
118}

References addNonScalableText(), and MARGIN.

Referenced by StratScene().

◆ addStratBar()

StratBar * StratScene::addStratBar ( GeoLib::StationBorehole * station,
std::map< std::string, DataHolderLib::Color > * stratColors = nullptr )
private

Add a stratigraphy-bar to the scene.

Definition at line 120 of file StratScene.cpp.

123{
124 auto* b = new StratBar(station, stratColors);
125 addItem(b);
126 return b;
127}

Referenced by StratScene().

Member Data Documentation

◆ MARGIN

const int StratScene::MARGIN = 50
static

The margin between the boundary of the scene and the bounding box of all items within the scene.

Definition at line 28 of file StratScene.h.

Referenced by StratScene(), addDepthLabels(), addSoilNameLabels(), StratView::saveAsImage(), and StratView::update().


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